mirror of
https://github.com/AndorsTrailRelease/andors-trail.git
synced 2025-12-28 23:35:47 +01:00
Compare commits
228 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f9d1dbdbae | ||
|
|
de59d8de8d | ||
|
|
718886ba3a | ||
|
|
cc123f76d6 | ||
|
|
a6ad03c534 | ||
|
|
45491871e6 | ||
|
|
8988f37896 | ||
|
|
09b4324873 | ||
|
|
a5a2764cb4 | ||
|
|
6de4d0c374 | ||
|
|
48c33d766b | ||
|
|
22493ee0e9 | ||
|
|
8afc3133c6 | ||
|
|
d0cfa29929 | ||
|
|
6a51d462d7 | ||
|
|
4f7cc4942c | ||
|
|
6631e01b64 | ||
|
|
133dffe330 | ||
|
|
6e5d17173f | ||
|
|
7463d15159 | ||
|
|
beff0f1b71 | ||
|
|
867ed36419 | ||
|
|
387c1e126f | ||
|
|
c9d7cda233 | ||
|
|
b75521da59 | ||
|
|
5f9ee8a410 | ||
|
|
296c3b453c | ||
|
|
6e2da63308 | ||
|
|
445cd9fe8e | ||
|
|
a0cc567694 | ||
|
|
70d084fba7 | ||
|
|
5236aa0bf9 | ||
|
|
0eccb511db | ||
|
|
88c17db72b | ||
|
|
098fb95653 | ||
|
|
21d6bb7b7d | ||
|
|
ce91c5c7c8 | ||
|
|
613ab9101e | ||
|
|
3fbc7cf65f | ||
|
|
dc18289d18 | ||
|
|
6473e231e4 | ||
|
|
33a61b7a57 | ||
|
|
c070a39f7c | ||
|
|
995ec0f697 | ||
|
|
6cba6872c9 | ||
|
|
8812f664e7 | ||
|
|
d9113b2dab | ||
|
|
ad0025ba03 | ||
|
|
984aa17cc0 | ||
|
|
4cad05ce6b | ||
|
|
197ab946be | ||
|
|
e4cdbc1840 | ||
|
|
04f00553ae | ||
|
|
0c02902ceb | ||
|
|
aba93fb15b | ||
|
|
1c8330b99a | ||
|
|
a8de7c2860 | ||
|
|
4ca8bbfc12 | ||
|
|
a5c004e4d4 | ||
|
|
e957e409e0 | ||
|
|
70d6340c11 | ||
|
|
bbbb69b175 | ||
|
|
4d5b7d8667 | ||
|
|
43da08f57d | ||
|
|
7b97367bdd | ||
|
|
e6fb647b99 | ||
|
|
5e4d7aba18 | ||
|
|
a96086b9af | ||
|
|
0566cf899c | ||
|
|
c8e87fb3d0 | ||
|
|
0a56a0ba86 | ||
|
|
026ccde2ff | ||
|
|
7813994b81 | ||
|
|
d3b070844f | ||
|
|
7a879f99b1 | ||
|
|
e810cdb3cb | ||
|
|
398be07c31 | ||
|
|
6db4c7bb3c | ||
|
|
c402824641 | ||
|
|
abc020e8f5 | ||
|
|
82caf260ce | ||
|
|
cbcf5ff8ca | ||
|
|
39d07bf8a8 | ||
|
|
93174f0d65 | ||
|
|
6afbeb9a2a | ||
|
|
a7cbd644f3 | ||
|
|
f674aff07c | ||
|
|
07b89a288c | ||
|
|
0264c418ca | ||
|
|
494b9c47cc | ||
|
|
6ff6c6dd6c | ||
|
|
00ab587265 | ||
|
|
67fa480805 | ||
|
|
91db56e7a7 | ||
|
|
36d52bedad | ||
|
|
c36b676720 | ||
|
|
5e0a999249 | ||
|
|
8fff4aff60 | ||
|
|
8c5344ff37 | ||
|
|
91e49b6c4a | ||
|
|
52cfb37b21 | ||
|
|
87886f08bb | ||
|
|
a31d7f9589 | ||
|
|
5600957f32 | ||
|
|
d6840a83c9 | ||
|
|
06fdd39648 | ||
|
|
b5763e7f76 | ||
|
|
75f01f20b9 | ||
|
|
dd366ab69e | ||
|
|
6ab443ec2c | ||
|
|
e0056cbf5c | ||
|
|
9f9397e1f3 | ||
|
|
d5a43cc7e1 | ||
|
|
408d8aa8b8 | ||
|
|
1e663069e8 | ||
|
|
dbcec1a199 | ||
|
|
04b4193548 | ||
|
|
058803184f | ||
|
|
5b5912c5bc | ||
|
|
759e632c07 | ||
|
|
6e311ecb64 | ||
|
|
b480fd9173 | ||
|
|
226459ddb8 | ||
|
|
92de033bc8 | ||
|
|
faf0dd061c | ||
|
|
9eaf9ea2ed | ||
|
|
00c4f77251 | ||
|
|
96ef9eedbb | ||
|
|
a5d94c03e2 | ||
|
|
9d15d380a3 | ||
|
|
bff780c837 | ||
|
|
0c493952c8 | ||
|
|
a1f6e1d29c | ||
|
|
fc71f43755 | ||
|
|
16afcf4886 | ||
|
|
b64a3c2109 | ||
|
|
5c0dc66183 | ||
|
|
3047f653bd | ||
|
|
393a478d13 | ||
|
|
560cb326f9 | ||
|
|
3fe2d7260f | ||
|
|
2cd4bc7ee5 | ||
|
|
19468b591d | ||
|
|
903117d32f | ||
|
|
f5bfc98c62 | ||
|
|
3274feb1e9 | ||
|
|
392b4d8577 | ||
|
|
92e4afde4b | ||
|
|
0c7724fe33 | ||
|
|
ca5be34fc2 | ||
|
|
28c3c7a0ec | ||
|
|
7f39cf1a6f | ||
|
|
365839571a | ||
|
|
5c3a04ca77 | ||
|
|
758a580063 | ||
|
|
ad5dbc9f9d | ||
|
|
4a86680928 | ||
|
|
ece63cf442 | ||
|
|
b487140a1b | ||
|
|
ad72bf8895 | ||
|
|
5919c429d2 | ||
|
|
0b6580e7c9 | ||
|
|
6efb2b3860 | ||
|
|
7ae084073f | ||
|
|
36df0b1732 | ||
|
|
b8fb100bd5 | ||
|
|
82b904d176 | ||
|
|
111aca868c | ||
|
|
2171c16d47 | ||
|
|
acd4d84783 | ||
|
|
cc25cc97f1 | ||
|
|
93ecebc448 | ||
|
|
f5713a3eb2 | ||
|
|
90001bb4d6 | ||
|
|
357cab9b1e | ||
|
|
5ea272f286 | ||
|
|
0c876bd1c5 | ||
|
|
0ac2999694 | ||
|
|
49af3c4b6d | ||
|
|
2a54b31d31 | ||
|
|
64766ce50a | ||
|
|
311accfdd3 | ||
|
|
2b5bf2fa4a | ||
|
|
64342c96d7 | ||
|
|
f8649bb0a5 | ||
|
|
fde6608c26 | ||
|
|
3f339c14a2 | ||
|
|
922db05c4d | ||
|
|
b849de8b66 | ||
|
|
f798b29729 | ||
|
|
e58e7a2588 | ||
|
|
a1ef339831 | ||
|
|
2002d51f6b | ||
|
|
025283b70b | ||
|
|
577b1aa034 | ||
|
|
da637c0cc8 | ||
|
|
d026ff690a | ||
|
|
d14ed56669 | ||
|
|
64cfacb7ff | ||
|
|
98a800e070 | ||
|
|
35219c8e88 | ||
|
|
b636cad347 | ||
|
|
733328cd29 | ||
|
|
36db28f805 | ||
|
|
6d4c1c3c14 | ||
|
|
eadb95f8e8 | ||
|
|
014f67f270 | ||
|
|
cd8657adb4 | ||
|
|
c007fc4d1c | ||
|
|
7e6c864ba3 | ||
|
|
f2da8f767a | ||
|
|
bd856541d6 | ||
|
|
bdde2176d9 | ||
|
|
171893a2c1 | ||
|
|
c6c1d6d03d | ||
|
|
ec8b114782 | ||
|
|
aaecb8ae4a | ||
|
|
4e2e3b370c | ||
|
|
c14f8f84a0 | ||
|
|
13c8012710 | ||
|
|
3806d77b26 | ||
|
|
af94220715 | ||
|
|
af07c47832 | ||
|
|
322007e5ac | ||
|
|
af5cdb9d49 | ||
|
|
68fa0068dc | ||
|
|
5dfa750227 | ||
|
|
cbe0773310 |
@@ -1,13 +1,13 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
compileSdkVersion 31
|
||||
buildToolsVersion "30.0.3"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.gpl.rpg.AndorsTrail"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 30
|
||||
targetSdkVersion 31
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
||||
@@ -3,15 +3,11 @@
|
||||
<manifest
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.gpl.rpg.AndorsTrail"
|
||||
android:versionCode="67"
|
||||
android:versionName="0.8.3"
|
||||
android:versionCode="73"
|
||||
android:versionName="0.8.7"
|
||||
android:installLocation="auto"
|
||||
>
|
||||
<uses-sdk
|
||||
android:minSdkVersion="4"
|
||||
android:targetSdkVersion="30"
|
||||
/>
|
||||
|
||||
|
||||
<supports-screens
|
||||
android:smallScreens="true"
|
||||
android:normalScreens="true"
|
||||
@@ -37,6 +33,7 @@
|
||||
>
|
||||
<activity
|
||||
android:name="com.gpl.rpg.AndorsTrail.activity.StartScreenActivity"
|
||||
android:exported="true"
|
||||
android:clearTaskOnLaunch="true"
|
||||
>
|
||||
<intent-filter>
|
||||
|
||||
@@ -24,15 +24,15 @@ public final class AndorsTrailApplication extends Application {
|
||||
public static final boolean DEVELOPMENT_DEBUGRESOURCES = false;
|
||||
public static final boolean DEVELOPMENT_FORCE_STARTNEWGAME = false;
|
||||
public static final boolean DEVELOPMENT_FORCE_CONTINUEGAME = false;
|
||||
public static final boolean DEVELOPMENT_DEBUGBUTTONS = false;
|
||||
public static final boolean DEVELOPMENT_DEBUGBUTTONS = true;
|
||||
public static final boolean DEVELOPMENT_FASTSPEED = false;
|
||||
public static final boolean DEVELOPMENT_VALIDATEDATA = false;
|
||||
public static final boolean DEVELOPMENT_DEBUGMESSAGES = false;
|
||||
public static final String CURRENT_VERSION_DISPLAY = "0.8.3";
|
||||
public static final boolean DEVELOPMENT_VALIDATEDATA = true;
|
||||
public static final boolean DEVELOPMENT_DEBUGMESSAGES = true;
|
||||
public static final String CURRENT_VERSION_DISPLAY = "0.8.7";
|
||||
public static final boolean IS_RELEASE_VERSION = !CURRENT_VERSION_DISPLAY.matches(".*[a-d].*");
|
||||
public static final boolean DEVELOPMENT_INCOMPATIBLE_SAVEGAMES = DEVELOPMENT_DEBUGRESOURCES || DEVELOPMENT_DEBUGBUTTONS || DEVELOPMENT_FASTSPEED || !IS_RELEASE_VERSION;
|
||||
public static final int DEVELOPMENT_INCOMPATIBLE_SAVEGAME_VERSION = 999;
|
||||
public static final int CURRENT_VERSION = DEVELOPMENT_INCOMPATIBLE_SAVEGAMES ? DEVELOPMENT_INCOMPATIBLE_SAVEGAME_VERSION : 67;
|
||||
public static final int CURRENT_VERSION = DEVELOPMENT_INCOMPATIBLE_SAVEGAMES ? DEVELOPMENT_INCOMPATIBLE_SAVEGAME_VERSION : 73;
|
||||
|
||||
private final AndorsTrailPreferences preferences = new AndorsTrailPreferences();
|
||||
private WorldContext world = new WorldContext();
|
||||
|
||||
@@ -78,7 +78,7 @@ public final class AndorsTrailPreferences {
|
||||
dest.dpadTransparency = Integer.parseInt(prefs.getString("dpadtransparency", Integer.toString(DPAD_TRANSPARENCY_50_PERCENT)));
|
||||
dest.dpadMinimizeable = prefs.getBoolean("dpadMinimizeable", true);
|
||||
dest.optimizedDrawing = prefs.getBoolean("optimized_drawing", false);
|
||||
dest.highQualityFilters = prefs.getBoolean("high_quality_filters", true);
|
||||
dest.highQualityFilters = prefs.getBoolean("high_quality_filters", false);
|
||||
dest.enableUiAnimations = prefs.getBoolean("enableUiAnimations", true);
|
||||
dest.displayOverwriteSavegame = Integer.parseInt(prefs.getString("display_overwrite_savegame", Integer.toString(CONFIRM_OVERWRITE_SAVEGAME_ALWAYS)));
|
||||
dest.quickslotsPosition = Integer.parseInt(prefs.getString("quickslots_placement", Integer.toString(QUICKSLOTS_POSITION_HORIZONTAL_CENTER_BOTTOM)));
|
||||
|
||||
@@ -11,9 +11,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.ClipData;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
@@ -122,8 +120,7 @@ public final class LoadSaveActivity extends AndorsTrailBaseActivity implements O
|
||||
|
||||
boolean hasSavegames = !Savegames.getUsedSavegameSlots(this).isEmpty();
|
||||
exportSaves.setEnabled(hasSavegames);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
exportImportContainer.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
@@ -133,12 +130,17 @@ public final class LoadSaveActivity extends AndorsTrailBaseActivity implements O
|
||||
private static final int WRITE_EXTERNAL_STORAGE_REQUEST = 2;
|
||||
|
||||
private void checkAndRequestPermissions() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) {
|
||||
if (getApplicationContext().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
this.requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, READ_EXTERNAL_STORAGE_REQUEST);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
||||
&& Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) {
|
||||
if (getApplicationContext().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
this.requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
|
||||
READ_EXTERNAL_STORAGE_REQUEST);
|
||||
}
|
||||
if (getApplicationContext().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
this.requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, WRITE_EXTERNAL_STORAGE_REQUEST);
|
||||
if (getApplicationContext().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
this.requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
|
||||
WRITE_EXTERNAL_STORAGE_REQUEST);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -152,11 +154,15 @@ public final class LoadSaveActivity extends AndorsTrailBaseActivity implements O
|
||||
}
|
||||
}
|
||||
|
||||
private void addSavegameSlotButtons(ViewGroup parent, LayoutParams params, List<Integer> usedSavegameSlots) {
|
||||
private void addSavegameSlotButtons(ViewGroup parent,
|
||||
LayoutParams params,
|
||||
List<Integer> usedSavegameSlots) {
|
||||
int unused = 1;
|
||||
for (int slot : usedSavegameSlots) {
|
||||
final FileHeader header = Savegames.quickload(this, slot);
|
||||
if (header == null) continue;
|
||||
if (header == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
while (unused < slot) {
|
||||
Button b = new Button(this);
|
||||
@@ -180,65 +186,76 @@ public final class LoadSaveActivity extends AndorsTrailBaseActivity implements O
|
||||
}
|
||||
}
|
||||
|
||||
private void cancelLoadSaveActivity(int slot){
|
||||
private void cancelLoadSaveActivity(int slot) {
|
||||
completeLoadSaveActivity(slot, false);
|
||||
}
|
||||
|
||||
private void completeLoadSaveActivity(int slot) {
|
||||
completeLoadSaveActivity(slot, true);
|
||||
}
|
||||
|
||||
private void completeLoadSaveActivity(int slot, boolean success) {
|
||||
Intent i = new Intent();
|
||||
if (slot == SLOT_NUMBER_CREATE_NEW_SLOT) {
|
||||
slot = getFirstFreeSlot();
|
||||
} else if (slot == SLOT_NUMBER_EXPORT_SAVEGAMES
|
||||
|| slot == SLOT_NUMBER_IMPORT_SAVEGAMES
|
||||
|| slot == SLOT_NUMBER_IMPORT_WORLDMAP) {
|
||||
|| slot == SLOT_NUMBER_IMPORT_SAVEGAMES
|
||||
|| slot == SLOT_NUMBER_IMPORT_WORLDMAP) {
|
||||
i.putExtra("import_export", true);
|
||||
|
||||
if(slot == SLOT_NUMBER_IMPORT_WORLDMAP){
|
||||
if (slot == SLOT_NUMBER_IMPORT_WORLDMAP) {
|
||||
i.putExtra("import_worldmap", true);
|
||||
}
|
||||
if(slot == SLOT_NUMBER_IMPORT_SAVEGAMES){
|
||||
if (slot == SLOT_NUMBER_IMPORT_SAVEGAMES) {
|
||||
i.putExtra("import_savegames", true);
|
||||
}
|
||||
if(slot == SLOT_NUMBER_EXPORT_SAVEGAMES){
|
||||
if (slot == SLOT_NUMBER_EXPORT_SAVEGAMES) {
|
||||
i.putExtra("export", true);
|
||||
}
|
||||
|
||||
} else if (slot < SLOT_NUMBER_FIRST_SLOT)
|
||||
} else if (slot < SLOT_NUMBER_FIRST_SLOT) {
|
||||
slot = SLOT_NUMBER_FIRST_SLOT;
|
||||
}
|
||||
|
||||
i.putExtra("slot", slot);
|
||||
if(success) setResult(Activity.RESULT_OK, i);
|
||||
else setResult(Activity.RESULT_CANCELED, i);
|
||||
if (success) {
|
||||
setResult(Activity.RESULT_OK, i);
|
||||
} else {
|
||||
setResult(Activity.RESULT_CANCELED, i);
|
||||
}
|
||||
LoadSaveActivity.this.finish();
|
||||
}
|
||||
|
||||
private int getFirstFreeSlot() {
|
||||
int slot;
|
||||
List<Integer> usedSlots = Savegames.getUsedSavegameSlots(this);
|
||||
if (usedSlots.isEmpty())
|
||||
if (usedSlots.isEmpty()) {
|
||||
slot = SLOT_NUMBER_FIRST_SLOT;
|
||||
else slot = Collections.max(usedSlots) + 1;
|
||||
} else {
|
||||
slot = Collections.max(usedSlots) + 1;
|
||||
}
|
||||
return slot;
|
||||
}
|
||||
|
||||
private String getConfirmOverwriteQuestion(int slot) {
|
||||
if (isLoading)
|
||||
if (isLoading) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return getConfirmOverwriteQuestionIgnoringLoading(slot);
|
||||
}
|
||||
|
||||
private String getConfirmOverwriteQuestionIgnoringLoading(int slot) {
|
||||
if (slot == SLOT_NUMBER_CREATE_NEW_SLOT)
|
||||
if (slot == SLOT_NUMBER_CREATE_NEW_SLOT) {
|
||||
return null;//creating a new savegame
|
||||
}
|
||||
|
||||
if (!Savegames.getSlotFile(slot, this).exists())
|
||||
if (!Savegames.getSlotFile(slot, this).exists()) {
|
||||
return null;//nothing in slot to overwrite
|
||||
}
|
||||
|
||||
if (preferences.displayOverwriteSavegame == AndorsTrailPreferences.CONFIRM_OVERWRITE_SAVEGAME_ALWAYS) {
|
||||
if (preferences.displayOverwriteSavegame
|
||||
== AndorsTrailPreferences.CONFIRM_OVERWRITE_SAVEGAME_ALWAYS) {
|
||||
return getString(R.string.loadsave_save_overwrite_confirmation_all);
|
||||
}
|
||||
if (preferences.displayOverwriteSavegame == AndorsTrailPreferences.CONFIRM_OVERWRITE_SAVEGAME_NEVER) {
|
||||
@@ -247,10 +264,14 @@ public final class LoadSaveActivity extends AndorsTrailBaseActivity implements O
|
||||
|
||||
final String currentPlayerName = model.player.getName();
|
||||
final FileHeader header = Savegames.quickload(this, slot);
|
||||
if (header == null) return null;
|
||||
if (header == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final String savedPlayerName = header.playerName;
|
||||
if (currentPlayerName.equals(savedPlayerName)) return null; //if the names match
|
||||
if (currentPlayerName.equals(savedPlayerName)) {
|
||||
return null; //if the names match
|
||||
}
|
||||
|
||||
return getString(R.string.loadsave_save_overwrite_confirmation, savedPlayerName, currentPlayerName);
|
||||
}
|
||||
@@ -259,7 +280,7 @@ public final class LoadSaveActivity extends AndorsTrailBaseActivity implements O
|
||||
public void onClick(View view) {
|
||||
final int slot = (Integer) view.getTag();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
switch (slot) {
|
||||
case SLOT_NUMBER_IMPORT_WORLDMAP:
|
||||
clickImportWorldmap();
|
||||
@@ -273,8 +294,9 @@ public final class LoadSaveActivity extends AndorsTrailBaseActivity implements O
|
||||
}
|
||||
}
|
||||
if (!isLoading
|
||||
&& slot != SLOT_NUMBER_CREATE_NEW_SLOT
|
||||
&& AndorsTrailApplication.CURRENT_VERSION == AndorsTrailApplication.DEVELOPMENT_INCOMPATIBLE_SAVEGAME_VERSION) {
|
||||
&& slot != SLOT_NUMBER_CREATE_NEW_SLOT
|
||||
&& AndorsTrailApplication.CURRENT_VERSION
|
||||
== AndorsTrailApplication.DEVELOPMENT_INCOMPATIBLE_SAVEGAME_VERSION) {
|
||||
if (!isOverwriteTargetInIncompatibleVersion(slot)) {
|
||||
saveOrOverwriteSavegame(slot);
|
||||
}
|
||||
@@ -288,7 +310,7 @@ public final class LoadSaveActivity extends AndorsTrailBaseActivity implements O
|
||||
private void saveOrOverwriteSavegame(int slot) {
|
||||
final String message = getConfirmOverwriteQuestion(slot);
|
||||
if (message != null) {
|
||||
showConfirmoverwriteQuestion(slot, message);
|
||||
showConfirmOverwriteQuestion(slot, message);
|
||||
} else {
|
||||
completeLoadSaveActivity(slot);
|
||||
}
|
||||
@@ -296,8 +318,11 @@ public final class LoadSaveActivity extends AndorsTrailBaseActivity implements O
|
||||
|
||||
private boolean isOverwriteTargetInIncompatibleVersion(int slot) {
|
||||
final FileHeader header = Savegames.quickload(this, slot);
|
||||
if (header != null && header.fileversion != AndorsTrailApplication.DEVELOPMENT_INCOMPATIBLE_SAVEGAME_VERSION) {
|
||||
final CustomDialog d = CustomDialogFactory.createErrorDialog(this, "Overwriting not allowed", "You are currently using a development version of Andor's trail. Overwriting a regular savegame is not allowed in development mode.");
|
||||
if (header != null
|
||||
&& header.fileversion != AndorsTrailApplication.DEVELOPMENT_INCOMPATIBLE_SAVEGAME_VERSION) {
|
||||
final CustomDialog d = CustomDialogFactory.createErrorDialog(this,
|
||||
"Overwriting not allowed",
|
||||
"You are currently using a development version of Andor's trail. Overwriting a regular savegame is not allowed in development mode.");
|
||||
CustomDialogFactory.show(d);
|
||||
return true;
|
||||
}
|
||||
@@ -306,28 +331,32 @@ public final class LoadSaveActivity extends AndorsTrailBaseActivity implements O
|
||||
|
||||
//region Imports/Exports
|
||||
|
||||
//region Export
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||
private void exportSaveGames(Intent data) {
|
||||
Uri uri = data.getData();
|
||||
|
||||
Context context = getApplicationContext();
|
||||
ContentResolver resolver = AndorsTrailApplication.getApplicationFromActivity(this).getContentResolver();
|
||||
ContentResolver resolver = AndorsTrailApplication.getApplicationFromActivity(this)
|
||||
.getContentResolver();
|
||||
|
||||
File storageDir = AndroidStorage.getStorageDirectory(context, Constants.FILENAME_SAVEGAME_DIRECTORY);
|
||||
DocumentFile source = DocumentFile.fromFile(storageDir);
|
||||
File storageDir = AndroidStorage.getStorageDirectory(context,
|
||||
Constants.FILENAME_SAVEGAME_DIRECTORY);
|
||||
DocumentFile target = DocumentFile.fromTreeUri(context, uri);
|
||||
if (target == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
DocumentFile[] files = source.listFiles();
|
||||
File[] files = storageDir.listFiles();
|
||||
if (files == null) {
|
||||
showErrorExportingSaveGamesUnknown();
|
||||
return;
|
||||
}
|
||||
|
||||
boolean hasExistingFiles = false;
|
||||
for (DocumentFile file :
|
||||
files) {
|
||||
for (File file : files) {
|
||||
String fileName = file.getName();
|
||||
if (fileName == null)
|
||||
continue;
|
||||
|
||||
DocumentFile existingFile = target.findFile(fileName);
|
||||
if (existingFile != null) {
|
||||
@@ -339,45 +368,70 @@ public final class LoadSaveActivity extends AndorsTrailBaseActivity implements O
|
||||
if (hasExistingFiles) {
|
||||
showConfirmOverwriteByExportQuestion(resolver, target, files);
|
||||
} else {
|
||||
exportSaveGamesFolderContentToFolder(resolver, target, files);
|
||||
exportSaveGamesFolderContentToFolder(target, files);
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||
private void exportSaveGamesFolderContentToFolder(ContentResolver resolver, DocumentFile target, DocumentFile[] files) {
|
||||
private void exportSaveGamesFolderContentToFolder(DocumentFile target, File[] files) {
|
||||
DocumentFile[] sourceFiles = new DocumentFile[files.length];
|
||||
|
||||
DocumentFile[] worldmapFiles = null;
|
||||
File[] worldmapFiles = null;
|
||||
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
DocumentFile file = files[i];
|
||||
File file = files[i];
|
||||
if (file.isFile()) {
|
||||
sourceFiles[i] = file;
|
||||
} else if (file.isDirectory() && Objects.equals(file.getName(), Constants.FILENAME_WORLDMAP_DIRECTORY)) {
|
||||
sourceFiles[i] = DocumentFile.fromFile(file);
|
||||
} else if (file.isDirectory() && Objects.equals(file.getName(),
|
||||
Constants.FILENAME_WORLDMAP_DIRECTORY)) {
|
||||
worldmapFiles = file.listFiles();
|
||||
}
|
||||
}
|
||||
Context context =this;
|
||||
DocumentFile[] finalWorldmapFiles = worldmapFiles;
|
||||
AndroidStorage.copyDocumentFilesToDirAsync(sourceFiles,
|
||||
context,
|
||||
target,
|
||||
(sucess) -> {
|
||||
if (sucess) {
|
||||
DocumentFile worldmapFolder = target.createDirectory(Constants.FILENAME_WORLDMAP_DIRECTORY);
|
||||
AndroidStorage.copyDocumentFilesToDirAsync(finalWorldmapFiles,
|
||||
context,
|
||||
worldmapFolder,
|
||||
(sucessWorldmap) -> completeLoadSaveActivity(SLOT_NUMBER_EXPORT_SAVEGAMES, sucessWorldmap));
|
||||
} else {
|
||||
completeLoadSaveActivity(SLOT_NUMBER_EXPORT_SAVEGAMES, false);
|
||||
}
|
||||
});
|
||||
Context context = this;
|
||||
File[] finalWorldmapFiles = worldmapFiles;
|
||||
CopyFilesToExternalFolder(target, sourceFiles, context, finalWorldmapFiles);
|
||||
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||
private void CopyFilesToExternalFolder(DocumentFile target,
|
||||
DocumentFile[] sourceFiles,
|
||||
Context context,
|
||||
File[] finalWorldmapFiles) {
|
||||
AndroidStorage.copyDocumentFilesToDirAsync(sourceFiles,
|
||||
context,
|
||||
target,
|
||||
getString(R.string.loadsave_exporting_savegames),
|
||||
(success) -> {
|
||||
if (success) {
|
||||
CopyWorldmapFilesAsZip(target,
|
||||
context,
|
||||
finalWorldmapFiles);
|
||||
} else {
|
||||
completeLoadSaveActivity(
|
||||
SLOT_NUMBER_EXPORT_SAVEGAMES,
|
||||
false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||
private void CopyWorldmapFilesAsZip(DocumentFile target,
|
||||
Context context,
|
||||
File[] finalWorldmapFiles) {
|
||||
AndroidStorage.createZipDocumentFileFromFilesAsync(finalWorldmapFiles,
|
||||
context,
|
||||
target,
|
||||
Constants.FILENAME_WORLDMAP_DIRECTORY,
|
||||
getString(R.string.loadsave_exporting_worldmap),
|
||||
(successWorldmap) -> completeLoadSaveActivity(
|
||||
SLOT_NUMBER_EXPORT_SAVEGAMES,
|
||||
successWorldmap));
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||
private void importSaveGames(Intent data) {
|
||||
Uri uri = data.getData();
|
||||
ClipData uris = data.getClipData();
|
||||
@@ -388,7 +442,8 @@ public final class LoadSaveActivity extends AndorsTrailBaseActivity implements O
|
||||
}
|
||||
|
||||
Context context = getApplicationContext();
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
ContentResolver resolver = AndorsTrailApplication.getApplicationFromActivity(this)
|
||||
.getContentResolver();
|
||||
|
||||
File storageDir = AndroidStorage.getStorageDirectory(context, Constants.FILENAME_SAVEGAME_DIRECTORY);
|
||||
DocumentFile appSavegameFolder = DocumentFile.fromFile(storageDir);
|
||||
@@ -397,14 +452,18 @@ public final class LoadSaveActivity extends AndorsTrailBaseActivity implements O
|
||||
if (uri != null) {
|
||||
uriList.add(uri);
|
||||
} else {
|
||||
for (int i = 0; i < uris.getItemCount(); i++)
|
||||
for (int i = 0; i < uris.getItemCount(); i++) {
|
||||
uriList.add(uris.getItemAt(i).getUri());
|
||||
}
|
||||
}
|
||||
importSaveGamesFromUris(context, resolver, appSavegameFolder, uriList);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
private void importSaveGamesFromUris(Context context, ContentResolver resolver, DocumentFile appSavegameFolder, List<Uri> uriList) {
|
||||
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||
private void importSaveGamesFromUris(Context context,
|
||||
ContentResolver resolver,
|
||||
DocumentFile appSavegameFolder,
|
||||
List<Uri> uriList) {
|
||||
int count = uriList.size();
|
||||
|
||||
ArrayList<DocumentFile> alreadyExistingFiles = new ArrayList<>();
|
||||
@@ -414,10 +473,11 @@ public final class LoadSaveActivity extends AndorsTrailBaseActivity implements O
|
||||
Uri item = uriList.get(i);
|
||||
DocumentFile itemFile = DocumentFile.fromSingleUri(context, item);
|
||||
boolean fileAlreadyExists = getExistsSavegameInOwnFiles(itemFile, appSavegameFolder);
|
||||
if (fileAlreadyExists)
|
||||
if (fileAlreadyExists) {
|
||||
alreadyExistingFiles.add(itemFile);
|
||||
else
|
||||
} else {
|
||||
newFiles.add(itemFile);
|
||||
}
|
||||
}
|
||||
|
||||
if (alreadyExistingFiles.size() > 0) {
|
||||
@@ -427,7 +487,10 @@ public final class LoadSaveActivity extends AndorsTrailBaseActivity implements O
|
||||
}
|
||||
}
|
||||
|
||||
private void importSaveGames(ContentResolver resolver, DocumentFile appSavegameFolder, List<DocumentFile> saveFiles) {
|
||||
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||
private void importSaveGames(ContentResolver resolver,
|
||||
DocumentFile appSavegameFolder,
|
||||
List<DocumentFile> saveFiles) {
|
||||
int size = saveFiles.size();
|
||||
DocumentFile[] sources = new DocumentFile[size];
|
||||
DocumentFile[] targets = new DocumentFile[size];
|
||||
@@ -457,21 +520,18 @@ public final class LoadSaveActivity extends AndorsTrailBaseActivity implements O
|
||||
}
|
||||
|
||||
AndroidStorage.copyDocumentFilesFromToAsync(sources,
|
||||
this,
|
||||
targets,
|
||||
(sucess) -> completeLoadSaveActivity(SLOT_NUMBER_IMPORT_SAVEGAMES, sucess));
|
||||
}
|
||||
|
||||
private void completeSavegameImportAndCheckIfDone(List<Integer> importsNeedingConfirmation, int slot) {
|
||||
importsNeedingConfirmation.remove((Object) slot);
|
||||
if (importsNeedingConfirmation.isEmpty()) {
|
||||
completeLoadSaveActivity(SLOT_NUMBER_IMPORT_SAVEGAMES);
|
||||
}
|
||||
this,
|
||||
targets,
|
||||
getString(R.string.loadsave_importing_savegames),
|
||||
(sucess) -> completeLoadSaveActivity(
|
||||
SLOT_NUMBER_IMPORT_SAVEGAMES,
|
||||
sucess));
|
||||
}
|
||||
|
||||
private boolean getExistsSavegameInOwnFiles(DocumentFile savegameFile, DocumentFile appSavegameFolder) {
|
||||
if (savegameFile == null)
|
||||
if (savegameFile == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DocumentFile foundFile = appSavegameFolder.findFile(Objects.requireNonNull(savegameFile.getName()));
|
||||
return foundFile != null && foundFile.exists();
|
||||
@@ -479,7 +539,6 @@ public final class LoadSaveActivity extends AndorsTrailBaseActivity implements O
|
||||
|
||||
private int getSlotFromSavegameFileName(String fileName) {
|
||||
if (fileName == null || !fileName.startsWith(Constants.FILENAME_SAVEGAME_FILENAME_PREFIX)) {
|
||||
//TODO: Maybe output a message that the file didn't have the right name?
|
||||
return -1;
|
||||
}
|
||||
String slotStr = fileName.substring(Constants.FILENAME_SAVEGAME_FILENAME_PREFIX.length());
|
||||
@@ -489,32 +548,16 @@ public final class LoadSaveActivity extends AndorsTrailBaseActivity implements O
|
||||
slot = Integer.parseInt(slotStr);
|
||||
return slot;
|
||||
} catch (NumberFormatException e) {
|
||||
//TODO: Maybe output a message that the file didn't have the right name?
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
private void importSaveGameFile(ContentResolver resolver, DocumentFile appSavegameFolder, DocumentFile itemFile, int slot) {
|
||||
String targetName = Savegames.getSlotFileName(slot);
|
||||
DocumentFile targetFile = getOrCreateDocumentFile(appSavegameFolder, targetName);
|
||||
|
||||
if (targetFile == null || !targetName.equals(targetFile.getName())) {
|
||||
showErrorImportingSaveGameUnknown();//TODO: maybe replace with a more specific error message
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
AndroidStorage.copyDocumentFile(itemFile, resolver, targetFile);
|
||||
} catch (IOException e) {
|
||||
showErrorImportingSaveGameUnknown();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private DocumentFile getOrCreateDocumentFile(DocumentFile folder, String targetName) {
|
||||
DocumentFile targetFile = folder.findFile(targetName);//try finding the file
|
||||
if (targetFile == null)//no file found, creating new one
|
||||
{
|
||||
targetFile = folder.createFile(Constants.NO_FILE_EXTENSION_MIME_TYPE, targetName);
|
||||
}
|
||||
return targetFile;
|
||||
}
|
||||
|
||||
@@ -522,72 +565,87 @@ public final class LoadSaveActivity extends AndorsTrailBaseActivity implements O
|
||||
private void importWorldmap(Intent data) {
|
||||
Uri uri = data.getData();
|
||||
|
||||
Context context = getApplicationContext();
|
||||
ContentResolver resolver = AndorsTrailApplication.getApplicationFromActivity(this).getContentResolver();
|
||||
Context context = AndorsTrailApplication.getApplicationFromActivity(this).getApplicationContext();
|
||||
|
||||
File storageDir = AndroidStorage.getStorageDirectory(context, Constants.FILENAME_SAVEGAME_DIRECTORY);
|
||||
DocumentFile storageFolder = DocumentFile.fromFile(storageDir);
|
||||
DocumentFile ownWorldmapFolder = storageFolder.findFile(Constants.FILENAME_WORLDMAP_DIRECTORY);
|
||||
if (ownWorldmapFolder == null) {
|
||||
ownWorldmapFolder = storageFolder.createDirectory(Constants.FILENAME_WORLDMAP_DIRECTORY);
|
||||
}
|
||||
|
||||
DocumentFile chosenFolder = DocumentFile.fromTreeUri(context, uri);
|
||||
if (chosenFolder == null || !chosenFolder.isDirectory()) {
|
||||
DocumentFile chosenZip = DocumentFile.fromSingleUri(context, uri);
|
||||
if (chosenZip == null || !chosenZip.isFile()) {
|
||||
showErrorImportingWorldmapWrongDirectory();
|
||||
return;
|
||||
}
|
||||
if (!Constants.FILENAME_WORLDMAP_DIRECTORY.equals(chosenFolder.getName())) {
|
||||
//user did not select the worldmap folder directly
|
||||
DocumentFile file = chosenFolder.findFile(Constants.FILENAME_WORLDMAP_DIRECTORY);
|
||||
if (file == null || !file.isDirectory() || !Constants.FILENAME_WORLDMAP_DIRECTORY.equals(file.getName())) {
|
||||
//could not find a worldmap folder in the users selection
|
||||
showErrorImportingWorldmapWrongDirectory();
|
||||
return;
|
||||
}
|
||||
|
||||
chosenFolder = file;
|
||||
String chosenZipName = chosenZip.getName();
|
||||
if (!chosenZipName.startsWith(Constants.FILENAME_WORLDMAP_DIRECTORY)) {
|
||||
showErrorImportingWorldmapWrongDirectory();
|
||||
return;
|
||||
}
|
||||
|
||||
AndroidStorage.copyDocumentFilesToDirAsync(chosenFolder.listFiles(),
|
||||
this,
|
||||
ownWorldmapFolder,
|
||||
(success) -> completeLoadSaveActivity(SLOT_NUMBER_IMPORT_WORLDMAP, success));
|
||||
File ownWorldmapFolder = getOwnWorldmapFolder(context);
|
||||
|
||||
|
||||
AndroidStorage.unzipDocumentFileToDirectoryAsync(chosenZip,
|
||||
this,
|
||||
ownWorldmapFolder,
|
||||
false,
|
||||
getString(R.string.loadsave_importing_worldmap),
|
||||
(success) -> completeLoadSaveActivity(
|
||||
SLOT_NUMBER_IMPORT_WORLDMAP,
|
||||
success));
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
private File getOwnWorldmapFolder(Context context) {
|
||||
File storageDir = AndroidStorage.getStorageDirectory(context, Constants.FILENAME_SAVEGAME_DIRECTORY);
|
||||
File ownWorldmapFolder = null;
|
||||
for (File f : storageDir.listFiles()) {
|
||||
if (f.getName().equals(Constants.FILENAME_WORLDMAP_DIRECTORY)) {
|
||||
ownWorldmapFolder = f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ownWorldmapFolder == null) {
|
||||
ownWorldmapFolder = new File(storageDir, Constants.FILENAME_WORLDMAP_DIRECTORY);
|
||||
ownWorldmapFolder.mkdir();
|
||||
}
|
||||
return ownWorldmapFolder;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||
private void clickExportSaveGames() {
|
||||
startActivityForResult(AndroidStorage.getNewOpenDirectoryIntent(), -SLOT_NUMBER_EXPORT_SAVEGAMES);
|
||||
showStartExportInfo(view -> startActivityForResult(AndroidStorage.getNewOpenDirectoryIntent(),
|
||||
-SLOT_NUMBER_EXPORT_SAVEGAMES));
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||
private void clickImportSaveGames() {
|
||||
startActivityForResult(AndroidStorage.getNewSelectMultipleSavegameFilesIntent(), -SLOT_NUMBER_IMPORT_SAVEGAMES);
|
||||
|
||||
showStartImportSavesInfo(view -> startActivityForResult(AndroidStorage.getNewSelectMultipleSavegameFilesIntent(),
|
||||
-SLOT_NUMBER_IMPORT_SAVEGAMES));
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||
private void clickImportWorldmap() {
|
||||
startActivityForResult(AndroidStorage.getNewOpenDirectoryIntent(), -SLOT_NUMBER_IMPORT_WORLDMAP);
|
||||
showStartImportWorldmapInfo(view -> startActivityForResult(AndroidStorage.getNewSelectZipIntent(),
|
||||
-SLOT_NUMBER_IMPORT_WORLDMAP));
|
||||
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||
private void showConfirmOverwriteByExportQuestion(ContentResolver resolver, DocumentFile targetFolder, DocumentFile[] files) {
|
||||
private void showConfirmOverwriteByExportQuestion(ContentResolver resolver,
|
||||
DocumentFile targetFolder,
|
||||
File[] files) {
|
||||
final CustomDialog d = CustomDialogFactory.createDialog(this,
|
||||
getString(R.string.loadsave_export_overwrite_confirmation_title),
|
||||
getResources().getDrawable(android.R.drawable.ic_dialog_alert),
|
||||
getString(R.string.loadsave_export_overwrite_confirmation),
|
||||
null,
|
||||
true);
|
||||
getString(R.string.loadsave_export_overwrite_confirmation_title),
|
||||
getResources().getDrawable(android.R.drawable.ic_dialog_alert),
|
||||
getString(R.string.loadsave_export_overwrite_confirmation),
|
||||
null,
|
||||
true);
|
||||
|
||||
CustomDialogFactory.addButton(d, android.R.string.yes, v -> exportSaveGamesFolderContentToFolder(resolver, targetFolder, files));
|
||||
CustomDialogFactory.addButton(d,
|
||||
android.R.string.yes,
|
||||
v -> exportSaveGamesFolderContentToFolder(targetFolder, files));
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.no);
|
||||
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||
private void showConfirmOverwriteByImportQuestion(ContentResolver resolver,
|
||||
DocumentFile appSavegameFolder,
|
||||
List<DocumentFile> alreadyExistingFiles,
|
||||
@@ -601,9 +659,9 @@ public final class LoadSaveActivity extends AndorsTrailBaseActivity implements O
|
||||
|
||||
Context context = AndorsTrailApplication.getApplicationFromActivity(this).getApplicationContext();
|
||||
|
||||
ArrayList<CustomDialog> dialogs = new ArrayList<CustomDialog>(amount) ;
|
||||
ArrayList<CustomDialog> dialogs = new ArrayList<>(amount);
|
||||
|
||||
for (int i = 0; i < amount ; i++) {
|
||||
for (int i = 0; i < amount; i++) {
|
||||
DocumentFile alreadyExistingFile = alreadyExistingFiles.get(i);
|
||||
int slot = getSlotFromSavegameFileName(alreadyExistingFile.getName());
|
||||
FileHeader existingFileHeader = Savegames.quickload(context, slot);
|
||||
@@ -620,20 +678,26 @@ public final class LoadSaveActivity extends AndorsTrailBaseActivity implements O
|
||||
}
|
||||
|
||||
StringBuilder messageSb = new StringBuilder();
|
||||
String existingFileDescription = getString(R.string.loadsave_import_existing_description, slot, existingFileHeader.describe());
|
||||
String importedFileDescription = getString(R.string.loadsave_import_imported_description, slot, importedFileHeader.describe());
|
||||
messageSb.append(getString(R.string.loadsave_import_file_exists_question, existingFileDescription, importedFileDescription));
|
||||
String existingFileDescription = getString(R.string.loadsave_import_existing_description,
|
||||
Integer.toString(slot),
|
||||
existingFileHeader.describe());
|
||||
String importedFileDescription = getString(R.string.loadsave_import_imported_description,
|
||||
Integer.toString(slot),
|
||||
importedFileHeader.describe());
|
||||
messageSb.append(getString(R.string.loadsave_import_file_exists_question,
|
||||
existingFileDescription,
|
||||
importedFileDescription));
|
||||
|
||||
|
||||
String m = messageSb.toString();
|
||||
CustomDialog dialog = CustomDialogFactory.createDialog(this,
|
||||
title,
|
||||
getResources().getDrawable(android.R.drawable.ic_dialog_alert),
|
||||
m,
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true);
|
||||
title,
|
||||
getResources().getDrawable(android.R.drawable.ic_dialog_alert),
|
||||
m,
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true);
|
||||
|
||||
CustomDialogFactory.addButton(dialog, R.string.loadsave_import_option_keep_existing, v -> {
|
||||
//do nothing
|
||||
@@ -646,7 +710,8 @@ public final class LoadSaveActivity extends AndorsTrailBaseActivity implements O
|
||||
});
|
||||
|
||||
CustomDialogFactory.addButton(dialog, R.string.loadsave_import_option_add_as_new, v -> {
|
||||
newFiles.add(null);//add a null element as marker to know later if the next file should be imported as new or overwrite the existing one
|
||||
newFiles.add(null);//add a null element as marker to know later if the next file
|
||||
// should be imported as new or overwrite the existing one
|
||||
newFiles.add(alreadyExistingFile);
|
||||
GoToNextConflictOrFinish(resolver, appSavegameFolder, newFiles, dialogs);
|
||||
});
|
||||
@@ -662,13 +727,15 @@ public final class LoadSaveActivity extends AndorsTrailBaseActivity implements O
|
||||
GoToNextConflictOrFinish(resolver, appSavegameFolder, newFiles, dialogs);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
private void GoToNextConflictOrFinish(ContentResolver resolver, DocumentFile appSavegameFolder, List<DocumentFile> newFiles, ArrayList<CustomDialog> dialogs) {
|
||||
if(dialogs.stream().count() > 0){
|
||||
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||
private void GoToNextConflictOrFinish(ContentResolver resolver,
|
||||
DocumentFile appSavegameFolder,
|
||||
List<DocumentFile> newFiles,
|
||||
ArrayList<CustomDialog> dialogs) {
|
||||
if (dialogs.stream().count() > 0) {
|
||||
CustomDialog d = dialogs.remove(0);
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
importSaveGames(resolver, appSavegameFolder, newFiles);
|
||||
}
|
||||
}
|
||||
@@ -677,8 +744,9 @@ public final class LoadSaveActivity extends AndorsTrailBaseActivity implements O
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
if (resultCode != Activity.RESULT_OK)
|
||||
if (resultCode != Activity.RESULT_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
switch (-requestCode) {
|
||||
@@ -713,48 +781,90 @@ public final class LoadSaveActivity extends AndorsTrailBaseActivity implements O
|
||||
|
||||
//region show Dialogs
|
||||
|
||||
private void showErrorImportingWorldmapWrongDirectory() {
|
||||
final CustomDialog d = CustomDialogFactory.createErrorDialog(this,
|
||||
getString(R.string.loadsave_import_worldmap_unsuccessfull),
|
||||
getString(R.string.loadsave_import_worldmap_wrong_directory));
|
||||
//region Import/Export
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||
private void showStartExportInfo(OnClickListener onOk) {
|
||||
final CustomDialog d = CustomDialogFactory.createDialog(this,
|
||||
getString(R.string.loadsave_export),
|
||||
getResources().getDrawable(android.R.drawable.ic_dialog_info),
|
||||
getString(R.string.loadsave_export_info),
|
||||
null,
|
||||
true);
|
||||
CustomDialogFactory.addButton(d, android.R.string.yes, onOk);
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.no);
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
|
||||
private void showErrorImportingSaveGameUnknown() {
|
||||
final CustomDialog d = CustomDialogFactory.createErrorDialog(this,
|
||||
getString(R.string.loadsave_import_save_unsuccessfull),
|
||||
getString(R.string.loadsave_import_save_error_unknown));
|
||||
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||
private void showStartImportSavesInfo(OnClickListener onOk) {
|
||||
final CustomDialog d = CustomDialogFactory.createDialog(this,
|
||||
getString(R.string.loadsave_import_save),
|
||||
getResources().getDrawable(android.R.drawable.ic_dialog_info),
|
||||
getString(R.string.loadsave_import_save_info),
|
||||
null,
|
||||
true);
|
||||
CustomDialogFactory.addButton(d, android.R.string.yes, onOk);
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.no);
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||
private void showStartImportWorldmapInfo(OnClickListener onOk) {
|
||||
final CustomDialog d = CustomDialogFactory.createDialog(this,
|
||||
getString(R.string.loadsave_import_worldmap),
|
||||
getResources().getDrawable(android.R.drawable.ic_dialog_info),
|
||||
getString(R.string.loadsave_import_worldmap_info),
|
||||
null,
|
||||
true);
|
||||
CustomDialogFactory.addButton(d, android.R.string.yes, onOk);
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.no);
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
|
||||
private void showErrorImportingWorldmapWrongDirectory() {
|
||||
final CustomDialog d = CustomDialogFactory.createErrorDialog(this,
|
||||
getString(R.string.loadsave_import_worldmap_unsuccessfull),
|
||||
getString(R.string.loadsave_import_worldmap_wrong_file));
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
|
||||
private void showErrorExportingSaveGamesUnknown() {
|
||||
final CustomDialog d = CustomDialogFactory.createErrorDialog(this,
|
||||
getString(R.string.loadsave_export_unsuccessfull),
|
||||
getString(R.string.loadsave_export_error_unknown));
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
private void showErrorLoadingEmptySlot() {
|
||||
final CustomDialog d = CustomDialogFactory.createErrorDialog(this,
|
||||
getString(R.string.startscreen_error_loading_game),
|
||||
getString(R.string.startscreen_error_loading_empty_slot));
|
||||
getString(R.string.startscreen_error_loading_game),
|
||||
getString(R.string.startscreen_error_loading_empty_slot));
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
|
||||
private void showSlotGetsDeletedOnLoadWarning(final int slot) {
|
||||
final CustomDialog d = CustomDialogFactory.createDialog(this,
|
||||
getString(R.string.startscreen_attention_slot_gets_delete_on_load),
|
||||
getResources().getDrawable(android.R.drawable.ic_dialog_alert),
|
||||
getString(R.string.startscreen_attention_message_slot_gets_delete_on_load),
|
||||
null,
|
||||
true);
|
||||
getString(R.string.startscreen_attention_slot_gets_delete_on_load),
|
||||
getResources().getDrawable(android.R.drawable.ic_dialog_alert),
|
||||
getString(R.string.startscreen_attention_message_slot_gets_delete_on_load),
|
||||
null,
|
||||
true);
|
||||
CustomDialogFactory.addButton(d, android.R.string.ok, v -> completeLoadSaveActivity(slot));
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
|
||||
private void showConfirmoverwriteQuestion(final int slot, String message) {
|
||||
final String title =
|
||||
getString(R.string.loadsave_save_overwrite_confirmation_title) + ' '
|
||||
+ getString(R.string.loadsave_save_overwrite_confirmation_slot, slot);
|
||||
private void showConfirmOverwriteQuestion(final int slot, String message) {
|
||||
final String title = getString(R.string.loadsave_save_overwrite_confirmation_title) + ' '
|
||||
+ getString(R.string.loadsave_save_overwrite_confirmation_slot, slot);
|
||||
final CustomDialog d = CustomDialogFactory.createDialog(this,
|
||||
title,
|
||||
getResources().getDrawable(android.R.drawable.ic_dialog_alert),
|
||||
message,
|
||||
null,
|
||||
true);
|
||||
title,
|
||||
getResources().getDrawable(android.R.drawable.ic_dialog_alert),
|
||||
message,
|
||||
null,
|
||||
true);
|
||||
|
||||
CustomDialogFactory.addButton(d, android.R.string.yes, v -> completeLoadSaveActivity(slot));
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.no);
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.gpl.rpg.AndorsTrail.util.ConstRange;
|
||||
import com.gpl.rpg.AndorsTrail.util.Range;
|
||||
|
||||
public final class Constants {
|
||||
public static final int PERCENT_EXP_LOST_WHEN_DIED = 30;
|
||||
public static final int PERCENT_EXP_LOST_WHEN_DIED = 20;
|
||||
public static final int LEVELUP_EFFECT_HEALTH = 5;
|
||||
public static final int LEVELUP_EFFECT_ATK_CH = 5;
|
||||
public static final int LEVELUP_EFFECT_ATK_DMG = 1;
|
||||
|
||||
@@ -83,7 +83,7 @@ public final class SkillCollection {
|
||||
public static final int PER_SKILLPOINT_INCREASE_COINFINDER_CHANCE_PERCENT = 30;
|
||||
public static final int PER_SKILLPOINT_INCREASE_MAGICFINDER_CHANCE_PERCENT = 50;
|
||||
public static final int PER_SKILLPOINT_INCREASE_COINFINDER_QUANTITY_PERCENT = 50;
|
||||
public static final int PER_SKILLPOINT_INCREASE_MORE_EXP_PERCENT = 5;
|
||||
public static final int PER_SKILLPOINT_INCREASE_MORE_EXP_PERCENT = 10;
|
||||
public static final int PER_SKILLPOINT_INCREASE_CLEAVE_AP = 3;
|
||||
public static final int PER_SKILLPOINT_INCREASE_EATER_HEALTH = 1;
|
||||
public static final int PER_SKILLPOINT_INCREASE_FORTITUDE_HEALTH = 1;
|
||||
|
||||
@@ -111,7 +111,7 @@ public final class Player extends Actor {
|
||||
baseTraits.criticalSkill = 0;
|
||||
baseTraits.criticalMultiplier = 1;
|
||||
baseTraits.damagePotential.set(1, 1);
|
||||
baseTraits.blockChance = 0;
|
||||
baseTraits.blockChance = 9;
|
||||
baseTraits.damageResistance = 0;
|
||||
baseTraits.useItemCost = 5;
|
||||
baseTraits.reequipCost = 5;
|
||||
|
||||
@@ -6,14 +6,12 @@ import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.support.v4.content.FileProvider;
|
||||
import android.support.v4.provider.DocumentFile;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.webkit.MimeTypeMap;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.controller.Constants;
|
||||
@@ -22,19 +20,22 @@ import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
public final class AndroidStorage {
|
||||
public static File getStorageDirectory(Context context, String name) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
return context.getExternalFilesDir(name);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
File root = Environment.getExternalStorageDirectory();
|
||||
return new File(root, name);
|
||||
}
|
||||
@@ -42,16 +43,16 @@ public final class AndroidStorage {
|
||||
|
||||
public static boolean shouldMigrateToInternalStorage(Context context) {
|
||||
boolean ret = false;
|
||||
File externalSaveGameDirectory = new File(Environment.getExternalStorageDirectory(), Constants.FILENAME_SAVEGAME_DIRECTORY);
|
||||
File externalSaveGameDirectory = new File(Environment.getExternalStorageDirectory(),
|
||||
Constants.FILENAME_SAVEGAME_DIRECTORY);
|
||||
File internalSaveGameDirectory = getStorageDirectory(context, Constants.FILENAME_SAVEGAME_DIRECTORY);
|
||||
|
||||
if (externalSaveGameDirectory.exists()
|
||||
&& externalSaveGameDirectory.isDirectory()
|
||||
&& externalSaveGameDirectory.listFiles().length > 0
|
||||
&& (
|
||||
!internalSaveGameDirectory.exists()
|
||||
|| internalSaveGameDirectory.isDirectory() && internalSaveGameDirectory.listFiles().length < 2)
|
||||
) {
|
||||
&& externalSaveGameDirectory.isDirectory()
|
||||
&& externalSaveGameDirectory.listFiles().length > 0
|
||||
&& (!internalSaveGameDirectory.exists()
|
||||
|| internalSaveGameDirectory.isDirectory()
|
||||
&& internalSaveGameDirectory.listFiles().length < 2)) {
|
||||
ret = true;
|
||||
}
|
||||
return ret;
|
||||
@@ -60,11 +61,11 @@ public final class AndroidStorage {
|
||||
public static boolean migrateToInternalStorage(Context context) {
|
||||
try {
|
||||
copy(new File(Environment.getExternalStorageDirectory(), Constants.CHEAT_DETECTION_FOLDER),
|
||||
getStorageDirectory(context, Constants.CHEAT_DETECTION_FOLDER));
|
||||
getStorageDirectory(context, Constants.CHEAT_DETECTION_FOLDER));
|
||||
copy(new File(Environment.getExternalStorageDirectory(), Constants.FILENAME_SAVEGAME_DIRECTORY),
|
||||
getStorageDirectory(context, Constants.FILENAME_SAVEGAME_DIRECTORY));
|
||||
getStorageDirectory(context, Constants.FILENAME_SAVEGAME_DIRECTORY));
|
||||
} catch (IOException e) {
|
||||
L.log("Error migrating data: " + e.toString());
|
||||
L.log("Error migrating data: " + e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -105,54 +106,174 @@ public final class AndroidStorage {
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||
public static void createZipDocumentFileFromFilesAsync(File[] files,
|
||||
Context context,
|
||||
DocumentFile targetDirectory,
|
||||
String fileName,
|
||||
String loadingMessage,
|
||||
Consumer<Boolean> callback) {
|
||||
|
||||
public static void copyDocumentFileToNewOrExistingFile(DocumentFile sourceFile, ContentResolver resolver, DocumentFile targetFolder) throws IOException {
|
||||
copyDocumentFileToNewOrExistingFile(sourceFile, resolver, targetFolder, Constants.NO_FILE_EXTENSION_MIME_TYPE);
|
||||
BackgroundWorker<Boolean> worker = new BackgroundWorker<>();
|
||||
CustomDialogFactory.CustomDialog progressDialog = getLoadingDialog(context, loadingMessage);
|
||||
progressDialog.setOnCancelListener(dialog -> worker.cancel());
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
Handler handler = Handler.createAsync(Looper.getMainLooper());
|
||||
|
||||
|
||||
worker.setTask(workerCallback -> {
|
||||
try {
|
||||
workerCallback.onInitialize();
|
||||
|
||||
//region create zip file
|
||||
File zip = File.createTempFile("temp_worldmap", ".zip");
|
||||
try (OutputStream out = new FileOutputStream(zip)) {
|
||||
ZipOutputStream zipOut = new ZipOutputStream(out);
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
File file = files[i];
|
||||
try (FileInputStream fis = new FileInputStream(file)) {
|
||||
workerCallback.onProgress((float) i / files.length);
|
||||
zipOut.putNextEntry(new ZipEntry(file.getName()));
|
||||
copyStream(fis, zipOut);
|
||||
zipOut.closeEntry();
|
||||
}
|
||||
}
|
||||
zipOut.close();
|
||||
}
|
||||
//endregion
|
||||
|
||||
DocumentFile worldmapZip = DocumentFile.fromFile(zip);
|
||||
DocumentFile worldmapTarget = targetDirectory.createFile("application/zip", fileName);
|
||||
if (worldmapTarget != null && worldmapTarget.exists()) {
|
||||
AndroidStorage.copyDocumentFile(worldmapZip, resolver, worldmapTarget);
|
||||
workerCallback.onComplete(true);
|
||||
} else {
|
||||
throw new FileNotFoundException("Could not create File");
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
if (worker.isCancelled()) {
|
||||
workerCallback.onFailure(new CancellationException("Cancelled"));
|
||||
} else {
|
||||
workerCallback.onFailure(e);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
workerCallback.onFailure(e);
|
||||
}
|
||||
});
|
||||
|
||||
worker.setCallback(getDefaultBackgroundWorkerCallback(handler, progressDialog, callback));
|
||||
worker.run();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void unzipToDirectory(File zipFile,
|
||||
File targetDirectory,
|
||||
boolean overwriteNotSkip) throws IOException {
|
||||
|
||||
try (ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile))) {
|
||||
unzipStreamToDirectory(targetDirectory, overwriteNotSkip, zis);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||
public static void unzipDocumentFileToDirectoryAsync(DocumentFile zipFile,
|
||||
Context context,
|
||||
File targetDirectory,
|
||||
boolean overwriteNotSkip,
|
||||
String loadingMessage,
|
||||
Consumer<Boolean> callback) {
|
||||
|
||||
BackgroundWorker<Boolean> worker = new BackgroundWorker<>();
|
||||
CustomDialogFactory.CustomDialog progressDialog = getLoadingDialog(context, loadingMessage);
|
||||
progressDialog.setOnCancelListener(dialog -> worker.cancel());
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
Handler handler = Handler.createAsync(Looper.getMainLooper());
|
||||
|
||||
worker.setTask(workerCallback -> {
|
||||
try {
|
||||
workerCallback.onInitialize();
|
||||
workerCallback.onProgress(-1);//set dummy progress since we don't know the
|
||||
// progress of the unzip
|
||||
unzipDocumentFileToDirectory(zipFile, resolver, targetDirectory, overwriteNotSkip);
|
||||
workerCallback.onComplete(true);
|
||||
} catch (IOException e) {
|
||||
workerCallback.onFailure(e);
|
||||
}
|
||||
});
|
||||
|
||||
worker.setCallback(getDefaultBackgroundWorkerCallback(handler, progressDialog, callback));
|
||||
worker.run();
|
||||
|
||||
}
|
||||
|
||||
public static void unzipDocumentFileToDirectory(DocumentFile zipFile,
|
||||
ContentResolver resolver,
|
||||
File targetDirectory,
|
||||
boolean overwriteNotSkip) throws IOException {
|
||||
try (ZipInputStream zis = new ZipInputStream(resolver.openInputStream(zipFile.getUri()))) {
|
||||
unzipStreamToDirectory(targetDirectory, overwriteNotSkip, zis);
|
||||
}
|
||||
}
|
||||
|
||||
private static void unzipStreamToDirectory(File targetDirectory,
|
||||
boolean overwriteNotSkip,
|
||||
ZipInputStream zis) throws IOException {
|
||||
ZipEntry entry;
|
||||
while ((entry = zis.getNextEntry()) != null) {
|
||||
File file = new File(targetDirectory, entry.getName());
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
file.mkdirs();
|
||||
} else {
|
||||
file.getParentFile().mkdirs();
|
||||
if (file.exists() && !overwriteNotSkip) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try (FileOutputStream fos = new FileOutputStream(file)) {
|
||||
copyStream(zis, fos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void copyDocumentFileToNewOrExistingFile(DocumentFile sourceFile,
|
||||
ContentResolver resolver,
|
||||
DocumentFile targetFolder) throws IOException {
|
||||
copyDocumentFileToNewOrExistingFile(sourceFile,
|
||||
resolver,
|
||||
targetFolder,
|
||||
Constants.NO_FILE_EXTENSION_MIME_TYPE);
|
||||
}
|
||||
|
||||
|
||||
public static void copyDocumentFileToNewOrExistingFile(DocumentFile sourceFile, ContentResolver resolver, DocumentFile targetFolder, String mimeType) throws IOException {
|
||||
public static void copyDocumentFileToNewOrExistingFile(DocumentFile sourceFile,
|
||||
ContentResolver resolver,
|
||||
DocumentFile targetFolder,
|
||||
String mimeType) throws IOException {
|
||||
String fileName = sourceFile.getName();
|
||||
DocumentFile file = targetFolder.findFile(fileName);
|
||||
if (file == null)
|
||||
if (file == null) {
|
||||
file = targetFolder.createFile(mimeType, fileName);
|
||||
if (file == null)
|
||||
}
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
AndroidStorage.copyDocumentFile(sourceFile, resolver, file);
|
||||
}
|
||||
|
||||
public static void copyDocumentFile(DocumentFile sourceFile, ContentResolver resolver, DocumentFile targetFile) throws IOException {
|
||||
public static void copyDocumentFile(DocumentFile sourceFile,
|
||||
ContentResolver resolver,
|
||||
DocumentFile targetFile) throws IOException {
|
||||
try (OutputStream outputStream = resolver.openOutputStream(targetFile.getUri());
|
||||
InputStream inputStream = resolver.openInputStream(sourceFile.getUri())) {
|
||||
copyStream(inputStream, outputStream);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the MIME-Type for a file.<p/>
|
||||
* Fallback value is '* / *' (without spaces) <p/>
|
||||
* Mostly copied together from: <a href="https://stackoverflow.com/q/8589645/17292289">StackOverflow</a>
|
||||
*/
|
||||
@NonNull
|
||||
public static String getMimeType(ContentResolver resolver, Uri uri) {
|
||||
String type = null;
|
||||
if (ContentResolver.SCHEME_CONTENT.equals(uri.getScheme())) {
|
||||
type = resolver.getType(uri);
|
||||
return type;
|
||||
}
|
||||
|
||||
final String extension = MimeTypeMap.getFileExtensionFromUrl(uri.getPath());
|
||||
if (extension != null) {
|
||||
type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension.toLowerCase());
|
||||
}
|
||||
if (type == null) {
|
||||
type = "*/*"; // fallback type.
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
public static String getUrlForFile(Context context, File worldmap) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
String applicationId = context.getPackageName();
|
||||
@@ -163,11 +284,9 @@ public final class AndroidStorage {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public static Intent getNewOpenDirectoryIntent() {
|
||||
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
|
||||
return intent;
|
||||
return new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@@ -179,50 +298,59 @@ public final class AndroidStorage {
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static void copyDocumentFilesFromToAsync(DocumentFile[] sources, Context context, DocumentFile[] targets, Consumer<Boolean> callback) {
|
||||
if(sources.length != targets.length)
|
||||
{
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public static Intent getNewSelectZipIntent() {
|
||||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType("application/zip");
|
||||
return intent;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||
public static void copyDocumentFilesFromToAsync(DocumentFile[] sources,
|
||||
Context context,
|
||||
DocumentFile[] targets,
|
||||
String loadingMessage,
|
||||
Consumer<Boolean> callback) {
|
||||
if (sources.length != targets.length) {
|
||||
throw new IllegalArgumentException("Both arrays, target & source have to have the same size");
|
||||
}
|
||||
|
||||
BackgroundWorker worker = new BackgroundWorker();
|
||||
CustomDialogFactory.CustomDialog progressDialog = getLoadingDialog(context);
|
||||
BackgroundWorker<Boolean> worker = new BackgroundWorker<>();
|
||||
|
||||
CustomDialogFactory.CustomDialog progressDialog = getLoadingDialog(context, loadingMessage);
|
||||
progressDialog.setOnCancelListener(dialog -> worker.cancel());
|
||||
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
Handler handler = Handler.createAsync(Looper.getMainLooper());
|
||||
|
||||
worker.setTask(new BackgroundWorker.worker() {
|
||||
@Override
|
||||
public void doWork(BackgroundWorkerCallback callback) {
|
||||
try {
|
||||
callback.onInitialize();
|
||||
for (int i = 0; i < sources.length ; i++) {
|
||||
if (worker.isCancelled()) {
|
||||
callback.onFailure(new CancellationException("Cancelled"));
|
||||
return;
|
||||
}
|
||||
DocumentFile source = sources[i];
|
||||
DocumentFile target = targets[i];
|
||||
|
||||
if(source == null || target == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
copyDocumentFile(source, resolver,target);
|
||||
float progress = i /(float) sources.length;
|
||||
callback.onProgress(progress);
|
||||
}
|
||||
callback.onComplete(true);
|
||||
} catch (NullPointerException e) {
|
||||
worker.setTask(workerCallback -> {
|
||||
try {
|
||||
workerCallback.onInitialize();
|
||||
for (int i = 0; i < sources.length; i++) {
|
||||
if (worker.isCancelled()) {
|
||||
callback.onFailure(new CancellationException("Cancelled"));
|
||||
workerCallback.onFailure(new CancellationException("Cancelled"));
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
callback.onFailure(e);
|
||||
DocumentFile source = sources[i];
|
||||
DocumentFile target = targets[i];
|
||||
|
||||
if (source == null || target == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
copyDocumentFile(source, resolver, target);
|
||||
float progress = i / (float) sources.length;
|
||||
workerCallback.onProgress(progress);
|
||||
}
|
||||
workerCallback.onComplete(true);
|
||||
} catch (NullPointerException e) {
|
||||
if (worker.isCancelled()) {
|
||||
workerCallback.onFailure(new CancellationException("Cancelled"));
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
workerCallback.onFailure(e);
|
||||
}
|
||||
});
|
||||
worker.setCallback(getDefaultBackgroundWorkerCallback(handler, progressDialog, callback));
|
||||
@@ -233,9 +361,10 @@ public final class AndroidStorage {
|
||||
public static void copyDocumentFilesToDirAsync(DocumentFile[] files,
|
||||
Context context,
|
||||
DocumentFile targetDirectory,
|
||||
String loadingMessage,
|
||||
Consumer<Boolean> callback) {
|
||||
BackgroundWorker<Boolean> worker = new BackgroundWorker<>();
|
||||
CustomDialogFactory.CustomDialog progressDialog = getLoadingDialog(context);
|
||||
CustomDialogFactory.CustomDialog progressDialog = getLoadingDialog(context, loadingMessage);
|
||||
progressDialog.setOnCancelListener(dialog -> worker.cancel());
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
Handler handler = Handler.createAsync(Looper.getMainLooper());
|
||||
@@ -249,11 +378,12 @@ public final class AndroidStorage {
|
||||
return;
|
||||
}
|
||||
DocumentFile file = files[i];
|
||||
if(file == null)
|
||||
if (file == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
copyDocumentFileToNewOrExistingFile(file, resolver, targetDirectory);
|
||||
float progress = i /(float) files.length;
|
||||
float progress = i / (float) files.length;
|
||||
workerCallback.onProgress(progress);
|
||||
}
|
||||
workerCallback.onComplete(true);
|
||||
@@ -270,10 +400,11 @@ public final class AndroidStorage {
|
||||
}
|
||||
|
||||
private static BackgroundWorkerCallback<Boolean> getDefaultBackgroundWorkerCallback(Handler handler,
|
||||
CustomDialogFactory.CustomDialog progressDialog,
|
||||
Consumer<Boolean> callback) {
|
||||
CustomDialogFactory.CustomDialog progressDialog,
|
||||
Consumer<Boolean> callback) {
|
||||
return new BackgroundWorkerCallback<Boolean>() {
|
||||
private int progress = -1;
|
||||
private int progress = -1;
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
handler.post(() -> {
|
||||
@@ -285,10 +416,17 @@ public final class AndroidStorage {
|
||||
public void onProgress(float progress) {
|
||||
handler.post(() -> {
|
||||
int intProgress = (int) (progress * 100);
|
||||
if(this.progress == intProgress)
|
||||
if (this.progress == intProgress) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.progress = intProgress;
|
||||
|
||||
if (progress == -1) {
|
||||
CustomDialogFactory.setDesc(progressDialog, null);
|
||||
return;
|
||||
}
|
||||
|
||||
CustomDialogFactory.setDesc(progressDialog, intProgress + "%");
|
||||
});
|
||||
}
|
||||
@@ -296,10 +434,7 @@ public final class AndroidStorage {
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
handler.post(() -> {
|
||||
progressDialog.dismiss();
|
||||
callback.accept(false);
|
||||
});
|
||||
this.onComplete(false);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
@@ -307,20 +442,31 @@ public final class AndroidStorage {
|
||||
public void onComplete(Boolean result) {
|
||||
handler.post(() -> {
|
||||
progressDialog.dismiss();
|
||||
callback.accept(true);
|
||||
callback.accept(result);
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static CustomDialogFactory.CustomDialog getLoadingDialog(Context context) {
|
||||
return CustomDialogFactory.createDialog(context,
|
||||
context.getResources().getString(R.string.dialog_loading_message),
|
||||
context.getResources().getDrawable(R.drawable.loading_anim),
|
||||
null,
|
||||
null,
|
||||
false,
|
||||
false);
|
||||
return getLoadingDialog(context, null);
|
||||
}
|
||||
|
||||
private static CustomDialogFactory.CustomDialog getLoadingDialog(Context context, String message) {
|
||||
if (message == null) {
|
||||
message = context.getResources().getString(R.string.dialog_loading_message);
|
||||
}
|
||||
|
||||
CustomDialogFactory.CustomDialog dialog = CustomDialogFactory.createDialog(context,
|
||||
message,
|
||||
context.getResources()
|
||||
.getDrawable(R.drawable.loading_anim),
|
||||
null,
|
||||
null,
|
||||
true,
|
||||
false);
|
||||
CustomDialogFactory.addCancelButton(dialog, android.R.string.no);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,14 +4,14 @@ import java.util.concurrent.Executors;
|
||||
|
||||
public final class BackgroundWorker<T> {
|
||||
boolean cancelled = false;
|
||||
worker task;
|
||||
BackgroundWorkerCallback callback;
|
||||
worker<T> task;
|
||||
BackgroundWorkerCallback<T> callback;
|
||||
|
||||
public void setTask(worker task) {
|
||||
public void setTask(worker<T> task) {
|
||||
this.task = task;
|
||||
}
|
||||
|
||||
public void setCallback(BackgroundWorkerCallback callback) {
|
||||
public void setCallback(BackgroundWorkerCallback<T> callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public final class BackgroundWorker<T> {
|
||||
}
|
||||
|
||||
interface worker<T> {
|
||||
void doWork(BackgroundWorkerCallback callback);
|
||||
void doWork(BackgroundWorkerCallback<T> callback);
|
||||
}
|
||||
|
||||
interface BackgroundWorkerCallback<T> {
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
BIN
AndorsTrail/assets/translation/da.mo
Normal file
BIN
AndorsTrail/assets/translation/da.mo
Normal file
Binary file not shown.
68736
AndorsTrail/assets/translation/da.po
Normal file
68736
AndorsTrail/assets/translation/da.po
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
BIN
AndorsTrail/assets/translation/lzh.mo
Normal file
BIN
AndorsTrail/assets/translation/lzh.mo
Normal file
Binary file not shown.
68736
AndorsTrail/assets/translation/lzh.po
Normal file
68736
AndorsTrail/assets/translation/lzh.po
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
BIN
AndorsTrail/assets/translation/sr.mo
Normal file
BIN
AndorsTrail/assets/translation/sr.mo
Normal file
Binary file not shown.
68781
AndorsTrail/assets/translation/sr.po
Normal file
68781
AndorsTrail/assets/translation/sr.po
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
BIN
AndorsTrail/assets/translation/vi.mo
Normal file
BIN
AndorsTrail/assets/translation/vi.mo
Normal file
Binary file not shown.
68738
AndorsTrail/assets/translation/vi.po
Normal file
68738
AndorsTrail/assets/translation/vi.po
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -21,6 +21,46 @@ Visit our forums on www.andorstrail.com for help, hints, tips and general discus
|
||||
|
||||
Changelog:
|
||||
|
||||
v0.8.5
|
||||
New quest 'Ratdom' with 139 new maps and 2 sub quests
|
||||
The loss of XP in case of death is now 20% instead of 30%
|
||||
Having raw meat cooked
|
||||
Translation updates and many minor bug fixes and enhancements
|
||||
|
||||
v0.8.4.1
|
||||
Export/Import: The worldmap, which consists of many small png files, is handled now as a zip file.
|
||||
Translation updates and many minor bug fixes and map enhancements
|
||||
|
||||
v0.8.3
|
||||
New quest "The Dead are Walking" with 38 new maps
|
||||
Export/Import function for savegames
|
||||
|
||||
v0.8.2
|
||||
Fix of a lost traveler in certain conditions
|
||||
Support of older mobiles again
|
||||
|
||||
v0.8.1
|
||||
New city Sullengard
|
||||
71 new maps and 6 new quests
|
||||
Monster kill count
|
||||
Controller support
|
||||
Translations updated
|
||||
Engine changes to support actual Android Studio
|
||||
|
||||
v0.7.17
|
||||
Fix of unloadable savegames in certain conditions
|
||||
|
||||
v0.7.16
|
||||
New quest 'Delivery'
|
||||
Fix of Killed-by-Kamelio bug, postman bug and typos
|
||||
Translations updated (Chinese 99%)
|
||||
|
||||
v0.7.15
|
||||
Fix of a notification crash bug
|
||||
Fix of missing scout and of a non disappearing Ortholion and Ehrenfest in certain conditions
|
||||
Various small changes and bug fixes
|
||||
Translations updated
|
||||
|
||||
v0.7.14
|
||||
2 new quests:
|
||||
"Climbing up is forbidden"
|
||||
|
||||
@@ -1,5 +1,139 @@
|
||||
I put both (release notes + forum announcement) into this source, so it will be easier to maintain them parallel:
|
||||
|
||||
|
||||
APK 72 (0.8.6.1) Another Ratdom bug fix
|
||||
|
||||
Release notes
|
||||
=============
|
||||
* Fixed: Not able to complete quest "More rats!"
|
||||
* Translation updates
|
||||
|
||||
|
||||
Forum announcement //2023-05-21
|
||||
==================
|
||||
Hello adventurers,
|
||||
|
||||
we had to create another bug fix version (v0.8.6.1)
|
||||
|
||||
[list]In certain cases the quest "More rats!" could not be completed.
|
||||
[/list]
|
||||
|
||||
|
||||
Here is is the link on our server: [url]https://andorstrail.com/static/AndorsTrail_v0.8.7.apk[/url]
|
||||
Google Play, F-Droid and Itch will follow soon.
|
||||
|
||||
|
||||
|
||||
APK 71 (0.8.6) Ratdom bug fixes
|
||||
|
||||
Release notes
|
||||
=============
|
||||
* Missing chest content fixed
|
||||
* Translation updates and other minor bug fixes
|
||||
|
||||
|
||||
Forum announcement //2023-05-14
|
||||
==================
|
||||
Hello adventurers,
|
||||
|
||||
we have another new version for you (v0.8.6)
|
||||
|
||||
[list]The chests near Flora's fountain are filled now, the crash is fixed.
|
||||
[/list]
|
||||
|
||||
[list]Clevred now offers his help with the four wells with endless patience.[/list]
|
||||
|
||||
[list]And some fixes of minor bugs and updates of the translations (Chinese is 100% again 8)).[/list]
|
||||
|
||||
|
||||
Here is is the link on our server: [url]https://andorstrail.com/static/AndorsTrail_v0.8.6.apk[/url]
|
||||
Google Play, F-Droid and Itch will follow soon.
|
||||
|
||||
|
||||
|
||||
APK 70 (0.8.5) Ratdom
|
||||
|
||||
Release notes
|
||||
=============
|
||||
* The new Ratdom area with 3 quests and 139 new maps
|
||||
* Translation updates and many minor bug fixes and enhancements
|
||||
|
||||
|
||||
Forum announcement //2023-01-29
|
||||
==================
|
||||
Hello adventurers,
|
||||
|
||||
we have another new version for you (v0.8.5 Ratdom)
|
||||
|
||||
[list]We have a huge new area with 139 new maps and 3 new quests:
|
||||
A big quest in a rat world and two other small quests you will find on your way.
|
||||
|
||||
This section is more for high-level players: the quests Lodar, Charwood, Colonel Lutarc and the starter quests Prohibited Substance and Rat Infestation are mandatory.
|
||||
Do you have these and also 9000 gold pieces with you, then you can dive into the new adventure.
|
||||
Just go home and take a nap - it's not really going to be refreshing...
|
||||
|
||||
You will find many new maps arranged as a maze. This area looks and feels different than the rest of Andor's path. It will also be a challenge for the high-level players who just run through new areas with no effort.
|
||||
(The scope took a long time to create, so don't expect to finish it in a few hours.)
|
||||
|
||||
A rat named Clevred will accompany you even though you don't see it. It's small enough to hide in your pocket or carry around. But he will talk to you, sometimes randomly, sometimes giving advice.
|
||||
[/list]
|
||||
|
||||
[list]The loss of XP in case of death is now 20% instead of 30%[/list]
|
||||
|
||||
[list]It is now possible to have your raw meat cooked by Gison's son Gael and in Remgard.[/list]
|
||||
|
||||
[list]We added the new Polished ring of the Protector in Remgard, and flipped the places of sale of the Guardian and Protector rings.[/list]
|
||||
|
||||
[list]Several other adjustments, not worth to list them all here[/list]
|
||||
|
||||
[list]And as always, we've fixed some minor bugs and updated the translations.[/list]
|
||||
|
||||
|
||||
Here is is the link on our server: [url]https://andorstrail.com/static/AndorsTrail_v0.8.5.apk[/url]
|
||||
Google Play, F-Droid and Itch will follow soon.
|
||||
|
||||
Have fun!
|
||||
|
||||
|
||||
PS
|
||||
I might be too harsh, so we added an early exit to the quest so you can come out and complete the quest even if you didn't actually reach the end.
|
||||
|
||||
|
||||
|
||||
|
||||
APK 69 (0.8.4.1) //Mostly harmless
|
||||
|
||||
Release notes
|
||||
=============
|
||||
* Export/Import: The worldmap, which consists of many small png files, is handled now as a zip file.
|
||||
* Translation updates and many minor bug fixes and map enhancements
|
||||
|
||||
|
||||
Forum announcement //2023-01-29
|
||||
==================
|
||||
Hello fellow adventurers,
|
||||
|
||||
Here is the actual release v0.8.4.1 with bugfixes, translations and little enhancements:
|
||||
|
||||
[list]The export/import is enhanced: The worldmap, which consists of many small png files, is handled now as a zip file. This is more convenient and much quicker.[/list]
|
||||
|
||||
[list]Fixes of several little bugs and typos[/list]
|
||||
[list]Especially the Pangitain break should be fixed now[/list]
|
||||
[list]Many map fixes and changes, most of them in the new area towards Sullengard and the haunted forest[/list]
|
||||
|
||||
[list]And as always we actualized the translations[/list]
|
||||
|
||||
Here is is the link on our server: [url]https://andorstrail.com/static/AndorsTrail_v0.8.4.1.apk[/url]
|
||||
Google Play, F-Droid and Itch will follow soon.
|
||||
|
||||
Have fun!
|
||||
|
||||
|
||||
|
||||
|
||||
APK 68 (0.8.4) //Mostly harmless (unneeded files - immediatly replaced by 69)
|
||||
|
||||
|
||||
APK 67 (0.8.3) //Haunted Forest 2022-11-04
|
||||
|
||||
Release notes (Google/Itch)
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 187 KiB After Width: | Height: | Size: 190 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 435 KiB After Width: | Height: | Size: 435 KiB |
@@ -78,16 +78,11 @@
|
||||
"iconID":"actorconditions_omi2:4",
|
||||
"name":"Requiescence",
|
||||
"category":"mental",
|
||||
"isPositive":1,
|
||||
"roundEffect":{
|
||||
"visualEffectID":"blueSwirl",
|
||||
"increaseCurrentHP":{
|
||||
"min":2,
|
||||
"max":2
|
||||
},
|
||||
"increaseCurrentAP":{
|
||||
"min":0,
|
||||
"max":0
|
||||
}
|
||||
},
|
||||
"abilityEffect":{
|
||||
|
||||
@@ -8125,6 +8125,20 @@
|
||||
{
|
||||
"id":"brv_fortune_fortunes_select",
|
||||
"replies":[
|
||||
{
|
||||
"nextPhraseID":"brv_fortune_come_back_much_later",
|
||||
"requires":[
|
||||
{
|
||||
"requireType":"random",
|
||||
"requireID":"5"
|
||||
},
|
||||
{
|
||||
"requireType":"questProgress",
|
||||
"requireID":"brv_nondisplay",
|
||||
"value":151
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nextPhraseID":"brv_fortune_andor_10",
|
||||
"requires":[
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user