Skip to content

Commit 56492df

Browse files
committed
Export import data option on data splash screen
1 parent 4719ce5 commit 56492df

File tree

3 files changed

+43
-7
lines changed

3 files changed

+43
-7
lines changed

android-project/app/src/main/java/org/diasurgical/devilutionx/DataActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ private boolean isMissingGameData() {
130130
(!fileManager.hasFile("spawn.mpq") || isDownloadingSpawn);
131131
}
132132

133+
public void importData(View view) {
134+
Intent intent = new Intent(this, ImportActivity.class);
135+
startActivity(intent);
136+
}
137+
133138
/**
134139
* Start downloading the shareware
135140
*/

android-project/app/src/main/java/org/diasurgical/devilutionx/ImportActivity.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
public class ImportActivity extends Activity {
2525

2626
private static final int IMPORT_REQUEST_CODE = 0xD1AB70;
27+
private boolean userConfirmed = false;
2728

2829
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
2930
@Override
@@ -36,12 +37,16 @@ protected void onCreate(Bundle savedInstanceState) {
3637
AlertDialog.Builder builder = new AlertDialog.Builder(this);
3738
builder.setMessage(getString(R.string.import_data_info, externalFilesDir));
3839
builder.setPositiveButton(R.string.ok_button, (dialog, which) -> {
40+
this.userConfirmed = true;
3941
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
4042
intent.addCategory(Intent.CATEGORY_OPENABLE);
4143
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
4244
intent.setType("*/*");
4345
startActivityForResult(intent, IMPORT_REQUEST_CODE);
4446
});
47+
builder.setOnDismissListener(dialog -> {
48+
if (!this.userConfirmed && !isFinishing()) finish();
49+
});
4550

4651
AlertDialog dialog = builder.create();
4752
dialog.show();
@@ -76,6 +81,8 @@ protected void onActivityResult(int requestCode, int resultCode, @Nullable Inten
7681

7782
AlertDialog dialog = builder.create();
7883
dialog.show();
84+
} else {
85+
super.onBackPressed();
7986
}
8087
}
8188

android-project/app/src/main/res/layout/activity_data.xml

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,37 @@
5454
app:layout_constraintEnd_toEndOf="parent"
5555
app:layout_constraintStart_toStartOf="parent" />
5656

57-
<Button
58-
android:id="@+id/download_button"
59-
android:layout_width="wrap_content"
57+
<LinearLayout
58+
android:id="@+id/import_buttons"
59+
android:layout_width="0dp"
6060
android:layout_height="wrap_content"
61+
android:layout_marginStart="16dp"
6162
android:layout_marginTop="16dp"
62-
android:onClick="sendDownloadRequest"
63-
android:text="@string/download_spawn"
63+
android:layout_marginEnd="16dp"
64+
android:gravity="center"
65+
android:orientation="horizontal"
6466
app:layout_constraintEnd_toEndOf="parent"
6567
app:layout_constraintStart_toStartOf="parent"
66-
app:layout_constraintTop_toBottomOf="@+id/spawn_guide" />
68+
app:layout_constraintTop_toBottomOf="@+id/spawn_guide">
69+
70+
<Button
71+
android:id="@+id/import_button"
72+
android:layout_width="wrap_content"
73+
android:layout_height="wrap_content"
74+
android:onClick="importData"
75+
android:text="Import Data" />
76+
<Space
77+
android:layout_width="16dp"
78+
android:layout_height="wrap_content" />
79+
80+
<Button
81+
android:id="@+id/download_button"
82+
android:layout_width="wrap_content"
83+
android:layout_height="wrap_content"
84+
android:onClick="sendDownloadRequest"
85+
android:text="@string/download_spawn" />
86+
87+
</LinearLayout>
6788

6889
<Button
6990
android:id="@+id/check_data_button"
@@ -98,6 +119,9 @@
98119
android:visibility="gone"
99120
app:layout_constraintEnd_toEndOf="parent"
100121
app:layout_constraintStart_toStartOf="parent"
101-
app:layout_constraintTop_toBottomOf="@+id/download_button" />
122+
app:layout_constraintTop_toBottomOf="@+id/import_buttons" />
123+
124+
<android.support.constraint.Group android:layout_width="wrap_content"
125+
android:layout_height="wrap_content" />
102126

103127
</android.support.constraint.ConstraintLayout>

0 commit comments

Comments
 (0)