-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Highlights: - Added new source book (new spells from Elemental Evil) - Added option to import new source packages - Added option to reset database to initial defaults - Added option to sort spells in ascending/descending order - Added option to exclude selected components in filter Fixes: - Fixed "Thaumaturgy" spell description - Fixed dropdown filters excluding results
- Loading branch information
Showing
23 changed files
with
464 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,67 @@ | ||
D&DB | ||
==== | ||
|
||
Android app and database for searching and displaying data for Dungeons and Dragons (5e). | ||
![Spell Pages](images/screen_group1.png) | ||
|
||
Pre-built binaries available in the [releases tab](https://github.com/dseguin/dndb/releases/tag/v0.1.0), or download the [latest release directly](https://github.com/dseguin/dndb/releases/download/v0.1.0/dndb-androidapi19-0.1.0.apk). | ||
Android app and database for searching and displaying data for Dungeons & Dragons (5e). | ||
|
||
Pre-built binaries available in the [releases tab](https://github.com/dseguin/dndb/releases/latest), or download the [latest release directly](https://github.com/dseguin/dndb/releases/download/v0.1.1/dndb-androidapi19-0.1.1.apk). | ||
|
||
Spells | ||
------ | ||
|
||
![Spell Filtering](images/screen_group2.png) | ||
|
||
Spells can be sorted and filtered, and selecting one shows further details. The spells included are only the ones available under the Open Game License. | ||
|
||
More spells can be imported from `Settings->Import Source`. These source packages follow a specific format. | ||
|
||
Source Package Format | ||
--------------------- | ||
|
||
[An example source package can be found here](app/src/main/res/raw/srd.zip). | ||
|
||
In order to be imported, a source package must be a zip archive with the following structure: | ||
``` | ||
Source.zip | ||
↳ Manifest.xml | ||
↳ [other files] | ||
``` | ||
|
||
The "other files" are specified in `Manifest.xml`. The manifest file sits at the top of the folder structure and contains a list of all other files to be processed by the app. | ||
Here's an example `Manifest.xml`: | ||
```xml | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Source> | ||
<ShortName>SRD</ShortName> | ||
<Name>Basic Rules</Name> | ||
<Spells> | ||
<AssetFile>spells_SRD_A-G.sql</AssetFile> | ||
<AssetFile>spells_SRD_H-P.sql</AssetFile> | ||
<AssetFile>spells_SRD_R-Z.sql</AssetFile> | ||
<AssetFile>spells_SRD_extra.sql</AssetFile> | ||
</Spells> | ||
</Source> | ||
``` | ||
|
||
At the moment, all specified asset files are processed as SQLite statements. | ||
|
||
D&DB's Database Design | ||
---------------------- | ||
|
||
D&DB expects SQLite DML statements for adding or updating the internal database. The current database definition [can be found here](app/src/main/res/raw/spells_ddl.sql). There are no enforced foreign keys to maintain compatibility with older versions of SQLite. Just assume that any table named `<table1>_<table2>` is a join table. An example SELECT query can be seen in the comments at the top of the [previously mentioned data definition file](app/src/main/res/raw/spells_ddl.sql). | ||
|
||
(entity relationship diagram to be added in the future for reference) | ||
|
||
License | ||
------- | ||
|
||
Source code specific to D&DB is released under the MIT License. | ||
|
||
Data for the "Basic Rules" and other included material is provided by [Wizards of the Coast](https://dnd.wizards.com) under the [Open Game License](https://media.wizards.com/2016/downloads/DND/SRD-OGL_V5.1.pdf). | ||
|
||
The "dragon ampersand" is part of the Dungeons & Dragons logo and [is available as a press asset from Wizards of the Coast](https://dnd.wizards.com/pressassets). | ||
|
||
This software was developed using Google's Android Studio, which is based on IntelliJ IDEA Community Edition, and released under the Apache v2 License. The software makes use of the Android SDK, which is subject to [the Android SDK terms and conditions](https://developer.android.com/studio/terms). | ||
|
||
Other than the base libraries provided by the Android SDK and JDK, all D&DB code is original and provided under the MIT License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
app/src/main/java/ca/printf/dndb/view/SettingsFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package ca.printf.dndb.view; | ||
|
||
import android.app.Activity; | ||
import android.content.DialogInterface; | ||
import android.content.Intent; | ||
import android.database.sqlite.SQLiteDatabase; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.Button; | ||
import androidx.appcompat.app.AlertDialog; | ||
import androidx.core.util.Supplier; | ||
import androidx.fragment.app.Fragment; | ||
import java.io.FileNotFoundException; | ||
import java.io.IOException; | ||
import ca.printf.dndb.R; | ||
import ca.printf.dndb.data.DndbSQLManager; | ||
|
||
public class SettingsFragment extends Fragment { | ||
private static final int FILEPICKER_RESULT = 0xF17E; | ||
|
||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
} | ||
|
||
public View onCreateView(LayoutInflater li, ViewGroup vg, Bundle b) { | ||
View v = li.inflate(R.layout.fragment_settings, vg, false); | ||
Button importBtn = v.findViewById(R.id.settings_import_source); | ||
importBtn.setOnClickListener(importBtnListener); | ||
Button resetBtn = v.findViewById(R.id.settings_reset_db); | ||
resetBtn.setOnClickListener(resetBtnListener); | ||
return v; | ||
} | ||
|
||
private View.OnClickListener importBtnListener = new View.OnClickListener() { | ||
public void onClick(View v) {showFilePicker();} | ||
}; | ||
|
||
private View.OnClickListener resetBtnListener = new View.OnClickListener() { | ||
public void onClick(View v) { | ||
Supplier<Void> resetAction = new Supplier<Void>() { | ||
public Void get() { | ||
resetDB(); | ||
return null; | ||
} | ||
}; | ||
confirmationDialog(getString(R.string.label_settings_reset_db_confim_msg), resetAction); | ||
} | ||
}; | ||
|
||
// https://riptutorial.com/android/example/14425/showing-a-file-chooser-and-reading-the-result | ||
private void showFilePicker() { | ||
Intent i = new Intent(Intent.ACTION_GET_CONTENT); | ||
i.setType("application/zip"); | ||
i.addCategory(Intent.CATEGORY_OPENABLE); | ||
i.putExtra(Intent.EXTRA_LOCAL_ONLY, true); | ||
startActivityForResult(i, FILEPICKER_RESULT); | ||
} | ||
|
||
public void onActivityResult(int requestCode, int resultCode, Intent data) { | ||
if(requestCode != FILEPICKER_RESULT || resultCode != Activity.RESULT_OK) | ||
return; | ||
try { | ||
DndbSQLManager dbman = new DndbSQLManager(getContext()); | ||
SQLiteDatabase db = dbman.getWritableDatabase(); | ||
dbman.execZipPackage(db, getActivity().getContentResolver().openInputStream(data.getData())); | ||
db.close(); | ||
} catch (FileNotFoundException | NullPointerException e) { | ||
Log.e("onActivityResult", "Error loading file from file picker", e); | ||
} catch (IOException e) { | ||
Log.e("onActivityResult", "Error processing SQL in " + data.getData().toString(), e); | ||
} | ||
} | ||
|
||
private void resetDB() { | ||
DndbSQLManager dbman = new DndbSQLManager(getContext()); | ||
SQLiteDatabase db = dbman.getWritableDatabase(); | ||
Log.d("resetDB", "Clearing database with onCreate()"); | ||
dbman.onCreate(db); | ||
db.close(); | ||
dbman.close(); | ||
} | ||
|
||
private void confirmationDialog(String msg, final Supplier<Void> confirmAction) { | ||
AlertDialog.Builder confirm = new AlertDialog.Builder(getContext()); | ||
confirm.setTitle(R.string.general_confirm_dialog_title); | ||
confirm.setMessage(msg); | ||
confirm.setNegativeButton(R.string.general_button_cancel, new DialogInterface.OnClickListener() { | ||
public void onClick(DialogInterface dialog, int which) {dialog.dismiss();} | ||
}); | ||
confirm.setPositiveButton(R.string.general_button_confirm, new DialogInterface.OnClickListener() { | ||
public void onClick(DialogInterface dialog, int which) {confirmAction.get();} | ||
}); | ||
confirm.create().show(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.