Reorganize strings. Close reader activity when page list throws an exception and notify it.

This commit is contained in:
inorichi 2015-11-16 19:33:33 +01:00
parent 75236559ca
commit e177edfee6
9 changed files with 74 additions and 72 deletions

View file

@ -15,7 +15,6 @@
android:theme="@style/AppTheme" > android:theme="@style/AppTheme" >
<activity <activity
android:name=".ui.main.MainActivity" android:name=".ui.main.MainActivity"
android:label="@string/label_main"
android:launchMode="singleTop" android:launchMode="singleTop"
android:theme="@style/AppTheme.NoActionBar" > android:theme="@style/AppTheme.NoActionBar" >
<intent-filter> <intent-filter>
@ -26,21 +25,18 @@
</activity> </activity>
<activity <activity
android:name=".ui.manga.MangaActivity" android:name=".ui.manga.MangaActivity"
android:label="@string/title_activity_manga_detail"
android:parentActivityName=".ui.main.MainActivity" > android:parentActivityName=".ui.main.MainActivity" >
</activity> </activity>
<activity <activity
android:name=".ui.reader.ReaderActivity" android:name=".ui.reader.ReaderActivity"
android:label="@string/title_activity_viewer" android:parentActivityName=".ui.manga.MangaActivity" >
android:parentActivityName=".ui.manga.MangaActivity"
android:theme="@style/AppTheme" >
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.manga.MangaActivity" /> android:value=".ui.manga.MangaActivity" />
</activity> </activity>
<activity <activity
android:name=".ui.setting.SettingsActivity" android:name=".ui.setting.SettingsActivity"
android:label="@string/title_activity_settings" android:label="@string/label_settings"
android:parentActivityName=".ui.main.MainActivity" > android:parentActivityName=".ui.main.MainActivity" >
</activity> </activity>

View file

@ -37,7 +37,7 @@ public class SourceFragment extends BaseRxFragment<SourcePresenter> {
View view = inflater.inflate(R.layout.fragment_source, container, false); View view = inflater.inflate(R.layout.fragment_source, container, false);
ButterKnife.bind(this, view); ButterKnife.bind(this, view);
setToolbarTitle(R.string.catalogues_title); setToolbarTitle(R.string.label_catalogues);
createAdapter(); createAdapter();

View file

@ -36,7 +36,7 @@ public class DownloadFragment extends BaseRxFragment<DownloadPresenter> {
View view = inflater.inflate(R.layout.fragment_download_queue, container, false); View view = inflater.inflate(R.layout.fragment_download_queue, container, false);
ButterKnife.bind(this, view); ButterKnife.bind(this, view);
setToolbarTitle(R.string.download_title); setToolbarTitle(R.string.label_download_queue);
downloadListLayout = new LinearLayoutManager(getActivity()); downloadListLayout = new LinearLayoutManager(getActivity());
downloadList.setLayoutManager(downloadListLayout); downloadList.setLayoutManager(downloadListLayout);

View file

@ -48,7 +48,7 @@ public class LibraryFragment extends BaseRxFragment<LibraryPresenter> {
Bundle savedInstanceState) { Bundle savedInstanceState) {
// Inflate the layout for this fragment // Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_library, container, false); View view = inflater.inflate(R.layout.fragment_library, container, false);
setToolbarTitle(getString(R.string.library_title)); setToolbarTitle(getString(R.string.label_library));
ButterKnife.bind(this, view); ButterKnife.bind(this, view);
createAdapter(); createAdapter();

View file

@ -30,6 +30,8 @@ public class MainActivity extends BaseActivity {
private Drawer drawer; private Drawer drawer;
private final static String SELECTED_ITEM = "selected_item";
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -45,19 +47,19 @@ public class MainActivity extends BaseActivity {
.withActionBarDrawerToggleAnimated(true) .withActionBarDrawerToggleAnimated(true)
.addDrawerItems( .addDrawerItems(
new PrimaryDrawerItem() new PrimaryDrawerItem()
.withName(R.string.library_title) .withName(R.string.label_library)
.withIdentifier(R.id.nav_drawer_library), .withIdentifier(R.id.nav_drawer_library),
// new PrimaryDrawerItem() // new PrimaryDrawerItem()
// .withName(R.string.recent_updates_title) // .withName(R.string.recent_updates_title)
// .withIdentifier(R.id.nav_drawer_recent_updates), // .withIdentifier(R.id.nav_drawer_recent_updates),
new PrimaryDrawerItem() new PrimaryDrawerItem()
.withName(R.string.catalogues_title) .withName(R.string.label_catalogues)
.withIdentifier(R.id.nav_drawer_catalogues), .withIdentifier(R.id.nav_drawer_catalogues),
new PrimaryDrawerItem() new PrimaryDrawerItem()
.withName(R.string.download_title) .withName(R.string.label_download_queue)
.withIdentifier(R.id.nav_drawer_downloads), .withIdentifier(R.id.nav_drawer_downloads),
new PrimaryDrawerItem() new PrimaryDrawerItem()
.withName(R.string.settings_title) .withName(R.string.label_settings)
.withIdentifier(R.id.nav_drawer_settings) .withIdentifier(R.id.nav_drawer_settings)
.withSelectable(false) .withSelectable(false)
) )
@ -90,6 +92,14 @@ public class MainActivity extends BaseActivity {
if (savedInstanceState == null) if (savedInstanceState == null)
drawer.setSelection(R.id.nav_drawer_library); drawer.setSelection(R.id.nav_drawer_library);
else
drawer.setSelection(savedInstanceState.getInt(SELECTED_ITEM), false);
}
@Override
protected void onSaveInstanceState(Bundle outState) {
outState.putInt(SELECTED_ITEM, drawer.getCurrentSelection());
super.onSaveInstanceState(outState);
} }
public void setFragment(Fragment fragment) { public void setFragment(Fragment fragment) {

View file

@ -26,6 +26,7 @@ import eu.kanade.mangafeed.ui.reader.viewer.horizontal.LeftToRightReader;
import eu.kanade.mangafeed.ui.reader.viewer.horizontal.RightToLeftReader; import eu.kanade.mangafeed.ui.reader.viewer.horizontal.RightToLeftReader;
import eu.kanade.mangafeed.ui.reader.viewer.vertical.VerticalReader; import eu.kanade.mangafeed.ui.reader.viewer.vertical.VerticalReader;
import eu.kanade.mangafeed.ui.reader.viewer.webtoon.WebtoonReader; import eu.kanade.mangafeed.ui.reader.viewer.webtoon.WebtoonReader;
import eu.kanade.mangafeed.util.ToastUtil;
import nucleus.factory.RequiresPresenter; import nucleus.factory.RequiresPresenter;
@RequiresPresenter(ReaderPresenter.class) @RequiresPresenter(ReaderPresenter.class)
@ -72,6 +73,11 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
viewer.updatePageNumber(); viewer.updatePageNumber();
} }
public void onPageListError() {
finish();
ToastUtil.showShort(this, R.string.page_list_error);
}
public void onPageChanged(int currentPageIndex, int totalPages) { public void onPageChanged(int currentPageIndex, int totalPages) {
String page = (currentPageIndex + 1) + "/" + totalPages; String page = (currentPageIndex + 1) + "/" + totalPages;
pageNumber.setText(page); pageNumber.setText(page);

View file

@ -70,7 +70,9 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
if (currentPage != 0) if (currentPage != 0)
view.setSelectedPage(currentPage); view.setSelectedPage(currentPage);
}, },
(view, error) -> Timber.e("An error occurred while downloading page list")); (view, error) -> {
view.onPageListError();
});
restartableReplay(GET_PAGE_IMAGES, restartableReplay(GET_PAGE_IMAGES,
this::getPageImagesObservable, this::getPageImagesObservable,
@ -133,9 +135,11 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
} }
private void onChapterChange() { private void onChapterChange() {
if (!isDownloaded) if (pageList != null) {
source.savePageList(chapter.url, pageList); if (!isDownloaded)
saveChapterProgress(); source.savePageList(chapter.url, pageList);
saveChapterProgress();
}
} }
private Observable<List<Page>> getPageListObservable() { private Observable<List<Page>> getPageListObservable() {

View file

@ -28,7 +28,7 @@ public class SettingsMainFragment extends PreferenceFragment {
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
((BaseActivity)getActivity()) ((BaseActivity)getActivity())
.setToolbarTitle(getString(R.string.settings_title)); .setToolbarTitle(getString(R.string.label_settings));
} }
private void registerSubpreference(int preferenceResource, PreferenceFragment fragment) { private void registerSubpreference(int preferenceResource, PreferenceFragment fragment) {

View file

@ -1,69 +1,44 @@
<resources> <resources>
<string name="app_name">Mangafeed</string> <string name="app_name">Mangafeed</string>
<!-- Activity labels --> <!-- Activities and fragments labels (toolbar title) -->
<string name="label_main">Mangafeed</string> <string name="label_settings">Settings</string>
<string name="label_download_queue">Download queue</string>
<string name="label_library">My library</string>
<string name="label_recent_updates">Recent updates</string>
<string name="label_catalogues">Catalogues</string>
<!-- Main Activity --> <!-- Actions -->
<string name="action_github">View on GitHub</string>
<string name="text_no_data">No data to display</string>
<!-- Dialogs -->
<string name="dialog_action_ok">OK</string>
<string name="dialog_action_delete">Delete</string>
<string name="dialog_action_cancel">Cancel</string>
<string name="dialog_error_title">Oops</string>
<string name="dialog_general_error_Message">There was an error making the request</string>
<string name="dialog_error_no_connection">Sorry, you need a connection to do that!</string>
<!-- Arrays -->
<string name="library_title">My library</string>
<string name="recent_updates_title">Recent updates</string>
<string name="catalogues_title">Catalogues</string>
<string name="settings_title">Settings</string>
<string name="title_activity_manga_detail">MangaDetailActivity</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string> <string name="action_settings">Settings</string>
<string name="action_search">Search</string> <string name="action_search">Search</string>
<string name="action_refresh">Refresh</string> <string name="action_refresh">Refresh</string>
<string name="library_search_hint">Title or author…</string> <string name="action_select_all">Select all</string>
<string name="action_mark_as_read">Mark as read</string>
<string name="action_mark_as_unread">Mark as unread</string>
<string name="action_download">Download</string>
<string name="action_delete">Delete</string> <string name="action_delete">Delete</string>
<string name="library_selection_title">Selected</string> <string name="action_favorite">Add to favorites</string>
<string name="title_activity_catalogue_list">CatalogueList</string> <string name="action_remove_favorite">Remove from favorites</string>
<string name="title_activity_manga_catalogue">MangaCatalogue</string>
<string name="author">Author</string>
<string name="chapters">Chapters</string>
<string name="genres">Genres</string>
<string name="artist">Artist</string>
<string name="status">Status</string>
<string name="description">Description</string>
<string name="manga_detail_tab">Info</string>
<string name="manga_chapters_tab">Chapters</string>
<string name="title_activity_viewer">ViewerActivity</string>
<!-- Preferences --> <!-- Preferences -->
<!-- Subsections -->
<string name="title_activity_settings">Settings</string>
<string name="pref_category_reader">Reader</string> <string name="pref_category_reader">Reader</string>
<string name="pref_category_accounts">Accounts</string> <string name="pref_category_accounts">Accounts</string>
<string name="pref_category_downloads">Downloads</string> <string name="pref_category_downloads">Downloads</string>
<!-- Reader section -->
<string name="pref_fullscreen_mode">Read in fullscreen</string> <string name="pref_fullscreen_mode">Read in fullscreen</string>
<string name="pref_viewer_type">Default viewer</string> <string name="pref_viewer_type">Default viewer</string>
<string name="left_to_right_viewer">Left to right</string> <string name="left_to_right_viewer">Left to right</string>
<string name="right_to_left_viewer">Right to left</string> <string name="right_to_left_viewer">Right to left</string>
<string name="vertical_viewer">Vertical</string> <string name="vertical_viewer">Vertical</string>
<string name="webtoon_viewer">Webtoon (experimental)</string> <string name="webtoon_viewer">Webtoon (experimental)</string>
<!-- Downloads section -->
<string name="pref_download_directory">Downloads directory</string> <string name="pref_download_directory">Downloads directory</string>
<string name="pref_download_threads">Download threads</string>
<!-- Login dialog -->
<string name="accounts_login_title">Login for %1$s</string> <string name="accounts_login_title">Login for %1$s</string>
<string name="username">Username</string> <string name="username">Username</string>
<string name="password">Password</string> <string name="password">Password</string>
@ -75,25 +50,36 @@
<string name="loading">Loading…</string> <string name="loading">Loading…</string>
<string name="unknown_error">Unknown error</string> <string name="unknown_error">Unknown error</string>
<!-- Library fragment -->
<string name="library_search_hint">Title or author…</string>
<string name="library_selection_title">Selected</string>
<string name="action_favorite">Add to favorites</string> <!-- Catalogue fragment -->
<string name="action_remove_favorite">Remove from favorites</string> <string name="source_requires_login">This source requires login</string>
<!-- Manga info fragment -->
<string name="manga_detail_tab">Info</string>
<string name="author">Author</string>
<string name="chapters">Chapters</string>
<string name="genres">Genres</string>
<string name="artist">Artist</string>
<string name="status">Status</string>
<string name="description">Description</string>
<!-- Manga chapters fragment -->
<string name="manga_chapters_tab">Chapters</string>
<string name="selected_chapters_title">Selected chapters: %1$d</string>
<!-- Reader activity -->
<string name="downloading">Downloading…</string> <string name="downloading">Downloading…</string>
<string name="download_progress">Downloaded %1$d%%</string> <string name="download_progress">Downloaded %1$d%%</string>
<string name="chapter_progress">Page: %1$d</string> <string name="chapter_progress">Page: %1$d</string>
<string name="source_requires_login">This source requires login</string> <string name="page_list_error">Error fetching page list. Is network available?</string>
<string name="action_select_all">Select all</string>
<string name="action_mark_as_read">Mark as read</string>
<string name="action_mark_as_unread">Mark as unread</string>
<string name="action_download">Download</string>
<string name="selected_chapters_title">Selected chapters: %1$d</string>
<!-- Library update service notifications -->
<string name="notification_progress">Update progress: %1$d/%2$d</string> <string name="notification_progress">Update progress: %1$d/%2$d</string>
<string name="notification_completed">Update completed</string> <string name="notification_completed">Update completed</string>
<string name="notification_no_new_chapters">No new chapters found</string> <string name="notification_no_new_chapters">No new chapters found</string>
<string name="notification_new_chapters">Found new chapters for:</string> <string name="notification_new_chapters">Found new chapters for:</string>
<string name="pref_download_threads">Download threads</string>
<string name="download_title">Download queue</string>
</resources> </resources>