Skip to content

Commit

Permalink
Merge pull request #113 from Carifio24/v4-2-0
Browse files Browse the repository at this point in the history
Updates for v4.2.0
  • Loading branch information
Carifio24 authored Nov 12, 2024
2 parents e570404 + 71ccac6 commit 3d7496d
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 18 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
applicationId "dnd.jon.spellbook"
minSdkVersion 24
targetSdkVersion 34
versionCode 4001003
versionName "4.1.3"
versionCode 4002000
versionName "4.2.0"
signingConfig signingConfigs.release

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Binary file removed app/release/app-release.aab
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ public void onUpdateEvent(String originalName) {
}

@Override
public void onDuplicateEvent(String characterName) {
public void onDuplicateEvent(String name) {
final Bundle args = new Bundle();
args.putParcelable(CreateCharacterDialog.PROFILE_KEY, viewModel.getProfileByName(characterName));
args.putParcelable(CreateCharacterDialog.PROFILE_KEY, viewModel.getProfileByName(name));
final CreateCharacterDialog dialog = new CreateCharacterDialog();
dialog.setArguments(args);
dialog.show(activity.getSupportFragmentManager(), duplicateTag);
Expand Down
7 changes: 3 additions & 4 deletions app/src/main/java/dnd/jon/spellbook/GlobalInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

class GlobalInfo {

static final Version VERSION = new Version(4,1,3);
static final Version VERSION = new Version(4,2,0);
static final String VERSION_CODE = VERSION.string();

// We don't always want to show an update message
// i.e. for updates that are pure bugfixes, the old message may be
// more useful to users
static final Version UPDATE_LOG_VERSION = new Version(4,1,0);
static final Version UPDATE_LOG_VERSION = new Version(4,2,0);
static final String UPDATE_LOG_CODE = UPDATE_LOG_VERSION.string();
static final int UPDATE_LOG_TITLE_ID = R.string.update_04_01_00_title;
static final int UPDATE_LOG_DESCRIPTION_ID = R.string.update_04_01_00_description;
static final int UPDATE_LOG_DESCRIPTION_ID = R.string.update_04_02_00_description;

static final int ANDROID_VERSION = android.os.Build.VERSION.SDK_INT;

Expand Down
19 changes: 13 additions & 6 deletions app/src/main/java/dnd/jon/spellbook/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1222,14 +1222,21 @@ public boolean dispatchTouchEvent(MotionEvent ev) {

@Override
public boolean dispatchKeyEvent(KeyEvent ev) {
// We only listen for action up events for closing the spell window
// We only listen for one of either the action up or down events for closing the spell window,
// based on whether we have a current search open or not.
// If we listen to both up and down, we'll get two separate events
// and the close animation doesn't get to finish[
// and the close animation doesn't get to finish
if (
!onTablet &&
spellWindowFragment != null &&
ev.getKeyCode() == KeyEvent.KEYCODE_BACK &&
ev.getAction() == KeyEvent.ACTION_UP
// The condition below a bit hard to read, but we want to close the spell window if:
// Search is empty and the action is keyup
// Search is not empty and the action is keydown
//
// We need the specific search/keyup handling to override the default behavior,
// which is the to clear the SearchView rather than close the spell window
(viewModel.hasSearchQuery() != (ev.getAction() == KeyEvent.ACTION_UP))
) {
closeSpellWindow();
return true;
Expand Down Expand Up @@ -1330,13 +1337,13 @@ private void showUpdateDialog(boolean checkIfNecessary) {
final boolean noCharacters = (characterNames == null) || characterNames.size() <= 0;
final boolean toShow = !checkIfNecessary || !(prefs.contains(key) || noCharacters);
if (toShow) {
final int titleID = GlobalInfo.UPDATE_LOG_TITLE_ID;
final int descriptionID = GlobalInfo.UPDATE_LOG_DESCRIPTION_ID;
final String title = getString(string.version_update_title, GlobalInfo.VERSION_CODE);
final String description = getString(GlobalInfo.UPDATE_LOG_DESCRIPTION_ID);
final Runnable onDismissAction = () -> {
final SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean(key, true).apply();
};
SpellbookUtils.showMessageDialog(this, titleID, descriptionID, false, onDismissAction);
SpellbookUtils.showMessageDialog(this, title, description, false, onDismissAction);
} else if (checkIfNecessary) {
final SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean(key, true).apply();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public interface NamedItemEventHandler {
void onUpdateEvent(String originalName);
void onDuplicateEvent(String characterName);
void onDuplicateEvent(String name);
void onDeleteEvent(String name);
void onExportEvent(String name);
void onCopyEvent(String name);
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/dnd/jon/spellbook/SpellbookUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static String stackTrace(Exception e) {
return sw.toString();
}

static void showMessageDialog(Context context, int titleID, int messageID, boolean mustPressOK, Runnable onDismissAction) {
static void showMessageDialog(Context context, String title, String message, boolean mustPressOK, Runnable onDismissAction) {
// Create the dialog builder
final AlertDialog.Builder b = new AlertDialog.Builder(context);

Expand All @@ -144,8 +144,8 @@ static void showMessageDialog(Context context, int titleID, int messageID, boole
b.setView(binding.getRoot());

// Set the title and message
binding.messageDialogTitle.setText(titleID);
binding.messageDialogMessage.setText(messageID);
binding.messageDialogTitle.setText(title);
binding.messageDialogMessage.setText(message);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){
// binding.messageDialogMessage.setText(Html.fromHtml(message, Html.FROM_HTML_MODE_LEGACY));
// } else{
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/dnd/jon/spellbook/SpellbookViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,10 @@ void setSearchQuery(CharSequence searchQuery) {
setFilterNeeded();
}

boolean hasSearchQuery() {
return searchQuery != null && !searchQuery.toString().isEmpty();
}

LiveData<Boolean> currentUseExpanded() {
return currentUseExpandedLD;
}
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@
<string name="regain_spent_slots">Recuperar Slots Gastos</string>

<!-- Version update info -->
<string name="version_update_title">Atualização da versão %1$s</string>
<string name="update_02_10_title">Atualização da Versão 2.10</string>
<string name="update_02_10_description">O grimório foi atualizado para incluir material do recém-lançado <b>Caldeirão de Tudo de Tasha</b>. Isso inclui:\n\n\u2022<b>Novos magias</b> adicionados ao Tasha\n\u2022Uma nova classe, o <b>Artífice</b>\n\u2022<b>Listas expandidas de magias</b> de Tasha\n\nEsta atualização também inclui novas <b>opções de filtragem</b>, para gerenciar listas de ortografia e pesquisas com mais facilidade. Você pode habilitar os novos feitiços e opções na tela de filtragem.</string>
<string name="update_02_11_title">Atualização da Versão 2.11</string>
Expand Down Expand Up @@ -516,6 +517,7 @@
<string name="update_04_00_00_description">O livro de feitiços foi atualizado com vários novos recursos: \n\n\u2022Agora é possível criar <b>feitiços caseiros</b> que podem ser organizados em <b>fontes personalizadas</b> (separados por campanha, por exemplo). exemplo). Os feitiços do Homebrew aparecem na tabela de feitiços e são compartilhados por todos os personagens.\n\n\u2022Agora é possível <b>exportar uma lista de feitiços</b> para um arquivo externo. As listas podem ser exportadas com todas as informações de cada feitiço ou em formato abreviado (como a tabela de feitiços do aplicativo). Os formatos de exportação disponíveis são <b>PDF, Markdown e HTML</b>.\n\n\u2022Os feitiços de <b>${bmt_name}</b> foram adicionados ao livro de feitiços.</string>
<string name="update_04_01_00_title">Atualização da versão 4.1.0</string>
<string name="update_04_01_00_description">O livro de feitiços foi atualizado para incluir feitiços do <b>2024 Manual do Jogador</b>. Como muitos dos feitiços deste livro são novas versões dos livros de referência anteriores, esta atualização também adiciona uma opção para <b>ocultar feitiços duplicados</b> entre o LDJ 2024 e os livros de referência anteriores. Desativar esta opção permitirá que ambas as versões sejam mostradas na lista de feitiços. Se esta opção estiver habilitada, pode-se escolher se prefere ver as versões <b>2024 ou 2014</b> dos feitiços. Essa configuração pode ser ajustada <b>caractere por caractere</b>.</string>
<string name="update_04_02_00_description">O livro de feitiços foi atualizado com as seguintes alterações:\n\n\u2022Agora é possível exportar perfis de personagens e fontes criadas (com feitiços) e importá-los de arquivos JSON.\n\n\u2022Corrigir um bug onde a animação de fechamento da janela de feitiço em um telefone pode ser interrompida incorretamente.</string>

<!-- Profile/source actions -->
<string name="rename">Renomear</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@
<string name="regain_spent_slots">Regain Spent Slots</string>

<!-- Version update info -->
<string name="version_update_title">Version %1$s</string>
<string name="update_02_10_title">Version 2.10 update</string>
<string name="update_02_10_description">The spellbook has been updated to include material from the newly-released <b>Tasha\'s Cauldron of Everything</b>. This includes:\n\n\u2022<b>New spells</b> added in Tasha\'s \n\u2022A new class, the <b>Artificer</b> \n\u2022Tasha\'s <b>expanded spell lists</b>\n\nThis update also includes new <b>filtering options</b>, to more easily manage spell lists and searching. You can enable the new spells and options from the filtering screen.</string>
<string name="update_02_11_title">Version 2.11 update</string>
Expand Down Expand Up @@ -518,6 +519,7 @@
<string name="update_04_00_00_description">The spellbook has been updated with several new features: \n\n\u2022It is now possible to create <b>homebrew spells</b> which can be organized into <b>custom sources</b> (separating by campaign, for example). Homebrew spells show up in the spell table and are shared across all characters.\n\n\u2022It is now possible to <b>export a spell list</b> to an external file. Lists can be exported with all of the information for each spell, or in an abbreviated format (like the app\'s spell table). Available export formats are <b>PDF, Markdown, and HTML</b>.\n\n\u2022The spells from <b>${bmt_name}</b> have been added to the spellbook.</string>
<string name="update_04_01_00_title">Version 4.1.0</string>
<string name="update_04_01_00_description">The spellbook has been updated to include spells from the <b>2024 Player\'s Handbook</b>. As many of the spells from this book are new versions of those from previous sourcebooks, this update also adds an option to <b>hide duplicate spells</b> between the 2024 PHB and previous sourcebooks. Toggling this option off will allow both versions to be shown in the spell list. If this option is enabled, one can choose whether they prefer to see <b>2024 or 2014</b> versions of the spells. This setting can be adjusted on a <b>character-by-character basis</b>.</string>
<string name="update_04_02_00_description">The spellbook has been updated with the following changes:\n\n\u2022It\'s now possible to export character profiles and created sources (with spells) to, and import them from, JSON files.\n\n\u2022Fix a bug where the closing animation for the spell window on a phone could be incorrectly interrupted.\n\n\u2022Fix issues with the text of Divine Word.</string>

<!-- Profile/source actions -->
<string name="rename">Rename</string>
Expand Down

0 comments on commit 3d7496d

Please sign in to comment.