From e177edfee6795e117659d26a531cc43c379cce76 Mon Sep 17 00:00:00 2001 From: inorichi Date: Mon, 16 Nov 2015 19:33:33 +0100 Subject: [PATCH] Reorganize strings. Close reader activity when page list throws an exception and notify it. --- app/src/main/AndroidManifest.xml | 8 +- .../ui/catalogue/SourceFragment.java | 2 +- .../ui/download/DownloadFragment.java | 2 +- .../mangafeed/ui/library/LibraryFragment.java | 2 +- .../mangafeed/ui/main/MainActivity.java | 18 +++- .../mangafeed/ui/reader/ReaderActivity.java | 6 ++ .../mangafeed/ui/reader/ReaderPresenter.java | 12 ++- .../ui/setting/SettingsMainFragment.java | 2 +- app/src/main/res/values/strings.xml | 94 ++++++++----------- 9 files changed, 74 insertions(+), 72 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c941898655..1bb8bd0207 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -15,7 +15,6 @@ android:theme="@style/AppTheme" > @@ -26,21 +25,18 @@ + android:parentActivityName=".ui.manga.MangaActivity" > diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/catalogue/SourceFragment.java b/app/src/main/java/eu/kanade/mangafeed/ui/catalogue/SourceFragment.java index bb74851cb5..671a421c7e 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/catalogue/SourceFragment.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/catalogue/SourceFragment.java @@ -37,7 +37,7 @@ public class SourceFragment extends BaseRxFragment { View view = inflater.inflate(R.layout.fragment_source, container, false); ButterKnife.bind(this, view); - setToolbarTitle(R.string.catalogues_title); + setToolbarTitle(R.string.label_catalogues); createAdapter(); diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/download/DownloadFragment.java b/app/src/main/java/eu/kanade/mangafeed/ui/download/DownloadFragment.java index 8cd6054e9f..258c5bc2f6 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/download/DownloadFragment.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/download/DownloadFragment.java @@ -36,7 +36,7 @@ public class DownloadFragment extends BaseRxFragment { View view = inflater.inflate(R.layout.fragment_download_queue, container, false); ButterKnife.bind(this, view); - setToolbarTitle(R.string.download_title); + setToolbarTitle(R.string.label_download_queue); downloadListLayout = new LinearLayoutManager(getActivity()); downloadList.setLayoutManager(downloadListLayout); diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/library/LibraryFragment.java b/app/src/main/java/eu/kanade/mangafeed/ui/library/LibraryFragment.java index e5d9191923..15f22a5dfd 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/library/LibraryFragment.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/library/LibraryFragment.java @@ -48,7 +48,7 @@ public class LibraryFragment extends BaseRxFragment { Bundle savedInstanceState) { // Inflate the layout for this fragment 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); createAdapter(); diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/main/MainActivity.java b/app/src/main/java/eu/kanade/mangafeed/ui/main/MainActivity.java index 08c053a03f..7c87a36fc7 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/main/MainActivity.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/main/MainActivity.java @@ -30,6 +30,8 @@ public class MainActivity extends BaseActivity { private Drawer drawer; + private final static String SELECTED_ITEM = "selected_item"; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -45,19 +47,19 @@ public class MainActivity extends BaseActivity { .withActionBarDrawerToggleAnimated(true) .addDrawerItems( new PrimaryDrawerItem() - .withName(R.string.library_title) + .withName(R.string.label_library) .withIdentifier(R.id.nav_drawer_library), // new PrimaryDrawerItem() // .withName(R.string.recent_updates_title) // .withIdentifier(R.id.nav_drawer_recent_updates), new PrimaryDrawerItem() - .withName(R.string.catalogues_title) + .withName(R.string.label_catalogues) .withIdentifier(R.id.nav_drawer_catalogues), new PrimaryDrawerItem() - .withName(R.string.download_title) + .withName(R.string.label_download_queue) .withIdentifier(R.id.nav_drawer_downloads), new PrimaryDrawerItem() - .withName(R.string.settings_title) + .withName(R.string.label_settings) .withIdentifier(R.id.nav_drawer_settings) .withSelectable(false) ) @@ -90,6 +92,14 @@ public class MainActivity extends BaseActivity { if (savedInstanceState == null) 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) { diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderActivity.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderActivity.java index 0bf8755975..5bdab93fd9 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderActivity.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderActivity.java @@ -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.vertical.VerticalReader; import eu.kanade.mangafeed.ui.reader.viewer.webtoon.WebtoonReader; +import eu.kanade.mangafeed.util.ToastUtil; import nucleus.factory.RequiresPresenter; @RequiresPresenter(ReaderPresenter.class) @@ -72,6 +73,11 @@ public class ReaderActivity extends BaseRxActivity { viewer.updatePageNumber(); } + public void onPageListError() { + finish(); + ToastUtil.showShort(this, R.string.page_list_error); + } + public void onPageChanged(int currentPageIndex, int totalPages) { String page = (currentPageIndex + 1) + "/" + totalPages; pageNumber.setText(page); diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderPresenter.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderPresenter.java index 423ca0a244..71ee701008 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderPresenter.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderPresenter.java @@ -70,7 +70,9 @@ public class ReaderPresenter extends BasePresenter { if (currentPage != 0) view.setSelectedPage(currentPage); }, - (view, error) -> Timber.e("An error occurred while downloading page list")); + (view, error) -> { + view.onPageListError(); + }); restartableReplay(GET_PAGE_IMAGES, this::getPageImagesObservable, @@ -133,9 +135,11 @@ public class ReaderPresenter extends BasePresenter { } private void onChapterChange() { - if (!isDownloaded) - source.savePageList(chapter.url, pageList); - saveChapterProgress(); + if (pageList != null) { + if (!isDownloaded) + source.savePageList(chapter.url, pageList); + saveChapterProgress(); + } } private Observable> getPageListObservable() { diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/setting/SettingsMainFragment.java b/app/src/main/java/eu/kanade/mangafeed/ui/setting/SettingsMainFragment.java index dbc92a6071..2458865426 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/setting/SettingsMainFragment.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/setting/SettingsMainFragment.java @@ -28,7 +28,7 @@ public class SettingsMainFragment extends PreferenceFragment { public void onResume() { super.onResume(); ((BaseActivity)getActivity()) - .setToolbarTitle(getString(R.string.settings_title)); + .setToolbarTitle(getString(R.string.label_settings)); } private void registerSubpreference(int preferenceResource, PreferenceFragment fragment) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6e7243ef34..5f321d91a0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,69 +1,44 @@ Mangafeed - - Mangafeed + + Settings + Download queue + My library + Recent updates + Catalogues - - - View on GitHub - - No data to display - - - - OK - Delete - Cancel - - Oops - There was an error making the request - Sorry, you need a connection to do that! - - - - My library - Recent updates - Catalogues - Settings - MangaDetailActivity - - Hello world! + Settings Search Refresh - Title or author… + Select all + Mark as read + Mark as unread + Download Delete - Selected - CatalogueList - MangaCatalogue - Author - Chapters - Genres - Artist - Status - Description - Info - Chapters - ViewerActivity + Add to favorites + Remove from favorites - - Settings + Reader Accounts Downloads + Read in fullscreen - Default viewer Left to right Right to left Vertical Webtoon (experimental) + Downloads directory + Download threads + Login for %1$s Username Password @@ -75,25 +50,36 @@ Loading… Unknown error + + Title or author… + Selected - Add to favorites - Remove from favorites + + This source requires login + + + Info + Author + Chapters + Genres + Artist + Status + Description + + + Chapters + Selected chapters: %1$d + + Downloading… Downloaded %1$d%% Page: %1$d - This source requires login - - Select all - Mark as read - Mark as unread - Download - Selected chapters: %1$d + Error fetching page list. Is network available? + Update progress: %1$d/%2$d Update completed No new chapters found Found new chapters for: - Download threads - Download queue