Skip to content

Commit

Permalink
tts: add org.coolreader.cmd.TTS_STOP ReaderAction intent
Browse files Browse the repository at this point in the history
  • Loading branch information
teleshoes committed Aug 30, 2022
1 parent 0a6dd32 commit d72af8d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions android/res/menu/cr3_reader_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<item android:title="@string/action_toggle_document_styles" android:id="@+id/cr3_mi_toggle_document_styles" android:numericShortcut="6" android:titleCondensed="@string/action_toggle_document_styles" android:orderInCategory="9"></item>
<item android:title="@string/action_toggle_text_autoformat" android:id="@+id/cr3_mi_toggle_text_autoformat" android:numericShortcut="6" android:titleCondensed="@string/action_toggle_document_styles" android:orderInCategory="9"></item>
<item android:title="@string/mi_tts_play" android:id="@+id/cr3_mi_tts_play" android:numericShortcut="6" android:titleCondensed="@string/dlg_about" android:orderInCategory="10"></item>
<item android:title="@string/mi_tts_stop" android:id="@+id/cr3_mi_tts_stop" android:numericShortcut="6" android:titleCondensed="@string/dlg_about" android:orderInCategory="10"></item>
<item android:title="@string/mi_exit" android:titleCondensed="@string/mi_exit" android:id="@+id/cr3_mi_exit" android:icon="@drawable/cr3_viewer_exit" android:orderInCategory="14" android:numericShortcut="8"></item>
<item android:title="@string/dlg_about" android:id="@+id/cr3_mi_about" android:numericShortcut="6" android:titleCondensed="@string/dlg_about" android:orderInCategory="11"></item>
<item android:title="@string/dlg_book_info" android:id="@+id/cr3_mi_book_info" android:numericShortcut="6" android:titleCondensed="@string/dlg_book_info" android:orderInCategory="12"></item>
Expand Down
1 change: 1 addition & 0 deletions android/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@
<string name="progress_downloading">Downloading</string>
<string name="mi_book_opds_root">Online catalogs</string>
<string name="mi_tts_play">Read Aloud</string>
<string name="mi_tts_stop">Stop Read Aloud</string>
<string name="options_format_image_scaling_block_scale">Block image max zoom</string>
<string name="options_format_image_scaling_mode_integer_factor">Integer scale</string>
<string name="options_format_image_scaling_block_mode">Block image scaling mode</string>
Expand Down
2 changes: 2 additions & 0 deletions android/src/org/coolreader/crengine/ReaderAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public String toString() {
public final static ReaderAction GO_BACK = new ReaderAction("GO_BACK", R.string.action_go_back, ReaderCommand.DCMD_LINK_BACK, 0, R.id.cr3_go_back ).setIconId(R.drawable.cr3_button_prev);
public final static ReaderAction GO_FORWARD = new ReaderAction("GO_FORWARD", R.string.action_go_forward, ReaderCommand.DCMD_LINK_FORWARD, 0, R.id.cr3_go_forward).setIconId(R.drawable.cr3_button_next);
public final static ReaderAction TTS_PLAY = new ReaderAction("TTS_PLAY", R.string.mi_tts_play, ReaderCommand.DCMD_TTS_PLAY, 0, R.id.cr3_mi_tts_play ).setIconId(R.drawable.cr3_button_tts); //.setActivateWithLongMenuKey()
public final static ReaderAction TTS_STOP = new ReaderAction("TTS_STOP", R.string.mi_tts_stop, ReaderCommand.DCMD_TTS_STOP, 0, R.id.cr3_mi_tts_stop ).setIconId(R.drawable.cr3_button_tts); //.setActivateWithLongMenuKey()
public final static ReaderAction TOGGLE_TITLEBAR = new ReaderAction("TOGGLE_TITLEBAR", R.string.action_toggle_titlebar, ReaderCommand.DCMD_TOGGLE_TITLEBAR, 0 );
public final static ReaderAction SHOW_POSITION_INFO_POPUP = new ReaderAction("SHOW_POSITION_INFO_POPUP", R.string.action_show_position_info, ReaderCommand.DCMD_SHOW_POSITION_INFO_POPUP, 0 );
public final static ReaderAction SHOW_DICTIONARY = new ReaderAction("SHOW_DICTIONARY", R.string.action_show_dictionary, ReaderCommand.DCMD_SHOW_DICTIONARY, 0);
Expand Down Expand Up @@ -242,6 +243,7 @@ public static ArrayList<ReaderAction> createList(ReaderAction ... actions) {
ABOUT,
BOOK_INFO,
TTS_PLAY,
TTS_STOP,
TOGGLE_TITLEBAR,
SHOW_POSITION_INFO_POPUP,
SHOW_DICTIONARY,
Expand Down
1 change: 1 addition & 0 deletions android/src/org/coolreader/crengine/ReaderCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public enum ReaderCommand
DCMD_ABOUT(2019),
DCMD_BOOK_INFO(2020),
DCMD_TTS_PLAY(2021),
DCMD_TTS_STOP(2883),
DCMD_TOGGLE_TITLEBAR(2022),
DCMD_SHOW_POSITION_INFO_POPUP(2023),
DCMD_SHOW_DICTIONARY(2024),
Expand Down
6 changes: 6 additions & 0 deletions android/src/org/coolreader/crengine/ReaderView.java
Original file line number Diff line number Diff line change
Expand Up @@ -2393,6 +2393,12 @@ public void onCommand(final ReaderCommand cmd, final int param, final Runnable o
}));
}
break;
case DCMD_TTS_STOP:
if(ttsToolbar != null){
log.i("DCMD_TTS_STOP: stopping TTS");
ttsToolbar.stopAndClose();
}
break;
case DCMD_TOGGLE_DOCUMENT_STYLES:
if (isBookLoaded())
toggleDocumentStyles();
Expand Down

0 comments on commit d72af8d

Please sign in to comment.