From 7282a7fb410e470824d9789c308b2f71552ac992 Mon Sep 17 00:00:00 2001 From: ap-atul Date: Sat, 19 Aug 2023 16:08:03 +0530 Subject: [PATCH 1/2] minor clean up and format --- .../database/converters/DateConverter.java | 6 ++--- .../org/ranobe/ranobe/models/Chapter.java | 23 ++++++++--------- .../java/org/ranobe/ranobe/models/Novel.java | 24 ++++++++---------- .../ranobe/network/repository/GithubRepo.java | 18 ++++++------- .../ranobe/sources/en/LightNovelBtt.java | 2 -- .../org/ranobe/ranobe/sources/en/Neovel.java | 23 +++++++++-------- .../org/ranobe/ranobe/sources/en/Ranobe.java | 2 +- .../org/ranobe/ranobe/ui/browse/Browse.java | 1 - .../ui/browse/viewmodel/BrowseViewModel.java | 3 --- .../ui/chapters/adapter/ChapterAdapter.java | 2 +- .../chapters/viewmodel/ChaptersViewModel.java | 2 +- .../org/ranobe/ranobe/ui/details/Details.java | 4 +-- .../details/viewmodel/DetailsViewModel.java | 2 ++ .../org/ranobe/ranobe/ui/library/Library.java | 2 +- .../ui/reader/viewmodel/ReaderViewModel.java | 1 - .../ui/search/viewmodel/SearchViewModel.java | 4 +-- .../settings/viewmodel/SettingsViewModel.java | 1 + .../ranobe/ui/views/RecyclerSwipeHelper.java | 17 ++++++------- .../java/org/ranobe/ranobe/util/Version.java | 23 +++++++++-------- app/src/main/res/drawable/ic_library.xml | 13 +++++++--- app/src/main/res/drawable/ic_mark_read.xml | 13 +++++++--- app/src/main/res/drawable/ic_mark_unread.xml | 13 +++++++--- app/src/main/res/layout/fragment_chapters.xml | 4 +-- app/src/main/res/layout/fragment_details.xml | 2 +- app/src/main/res/layout/fragment_library.xml | 5 ++-- app/src/main/res/layout/fragment_search.xml | 8 +++--- app/src/main/res/layout/fragment_settings.xml | 13 +++++----- app/src/main/res/layout/item_page.xml | 6 ++--- .../main/res/layout/item_search_result.xml | 12 ++++----- .../res/layout/sheet_customize_reader.xml | 11 ++++---- app/src/main/res/navigation/nav_graph.xml | 2 +- app/src/main/res/values/themes.xml | 3 +-- core/src/main/AndroidManifest.xml | 2 +- .../java/org/ranobe/core/models/Chapter.java | 23 ++++++++--------- .../java/org/ranobe/core/models/Novel.java | 25 ++++++++----------- 35 files changed, 162 insertions(+), 153 deletions(-) diff --git a/app/src/main/java/org/ranobe/ranobe/database/converters/DateConverter.java b/app/src/main/java/org/ranobe/ranobe/database/converters/DateConverter.java index a2d7715..28f9b0a 100644 --- a/app/src/main/java/org/ranobe/ranobe/database/converters/DateConverter.java +++ b/app/src/main/java/org/ranobe/ranobe/database/converters/DateConverter.java @@ -6,12 +6,12 @@ public class DateConverter { @TypeConverter - public static Date toDate(Long dateLong){ - return dateLong == null ? null: new Date(dateLong); + public static Date toDate(Long dateLong) { + return dateLong == null ? null : new Date(dateLong); } @TypeConverter - public static Long fromDate(Date date){ + public static Long fromDate(Date date) { return date == null ? null : date.getTime(); } } diff --git a/app/src/main/java/org/ranobe/ranobe/models/Chapter.java b/app/src/main/java/org/ranobe/ranobe/models/Chapter.java index 87305cf..85e5cb4 100644 --- a/app/src/main/java/org/ranobe/ranobe/models/Chapter.java +++ b/app/src/main/java/org/ranobe/ranobe/models/Chapter.java @@ -10,6 +10,17 @@ @Entity public class Chapter implements Parcelable { + public static final Creator CREATOR = new Creator() { + @Override + public Chapter createFromParcel(Parcel in) { + return new Chapter(in); + } + + @Override + public Chapter[] newArray(int size) { + return new Chapter[size]; + } + }; @PrimaryKey @NonNull public String url; @@ -39,18 +50,6 @@ protected Chapter(Parcel in) { id = in.readFloat(); } - public static final Creator CREATOR = new Creator() { - @Override - public Chapter createFromParcel(Parcel in) { - return new Chapter(in); - } - - @Override - public Chapter[] newArray(int size) { - return new Chapter[size]; - } - }; - @NonNull @Override public String toString() { diff --git a/app/src/main/java/org/ranobe/ranobe/models/Novel.java b/app/src/main/java/org/ranobe/ranobe/models/Novel.java index 90e9529..e80adb9 100644 --- a/app/src/main/java/org/ranobe/ranobe/models/Novel.java +++ b/app/src/main/java/org/ranobe/ranobe/models/Novel.java @@ -14,13 +14,23 @@ @Entity public class Novel implements Parcelable { + public static final Creator CREATOR = new Creator() { + @Override + public Novel createFromParcel(Parcel in) { + return new Novel(in); + } + + @Override + public Novel[] newArray(int size) { + return new Novel[size]; + } + }; @PrimaryKey public long id; public int sourceId; public String name; public String cover; public String url; - public String status; public String summary; public List alternateNames; @@ -49,18 +59,6 @@ protected Novel(Parcel in) { year = in.readInt(); } - public static final Creator CREATOR = new Creator() { - @Override - public Novel createFromParcel(Parcel in) { - return new Novel(in); - } - - @Override - public Novel[] newArray(int size) { - return new Novel[size]; - } - }; - @NonNull @Override public String toString() { diff --git a/app/src/main/java/org/ranobe/ranobe/network/repository/GithubRepo.java b/app/src/main/java/org/ranobe/ranobe/network/repository/GithubRepo.java index 987f003..92eace0 100644 --- a/app/src/main/java/org/ranobe/ranobe/network/repository/GithubRepo.java +++ b/app/src/main/java/org/ranobe/ranobe/network/repository/GithubRepo.java @@ -16,16 +16,10 @@ public class GithubRepo { }}; private final Executor executor; - public GithubRepo(){ + public GithubRepo() { this.executor = Executors.newCachedThreadPool(); } - public interface Callback { - void onComplete(T result); - - void onError(Exception e); - } - public void getLatestRelease(Callback callback) { this.executor.execute(() -> { try { @@ -45,11 +39,11 @@ private GithubRelease fetchLatestRelease() throws Exception { Version latestVersion = new Version(Version.extractVersionNumber(tag)); Version currentVersion = new Version(Version.extractVersionNumber(BuildConfig.VERSION_NAME)); - if(latestVersion.get().equals(currentVersion.get())) { + if (latestVersion.get().equals(currentVersion.get())) { return new GithubRelease(false, currentVersion.get(), null); } - if(latestVersion.compareTo(currentVersion) > 0) { + if (latestVersion.compareTo(currentVersion) > 0) { String url = response.getString("html_url"); return new GithubRelease(true, tag, url); } @@ -57,6 +51,12 @@ private GithubRelease fetchLatestRelease() throws Exception { return new GithubRelease(false, currentVersion.get(), null); } + public interface Callback { + void onComplete(T result); + + void onError(Exception e); + } + public static class GithubRelease { public boolean updateAvailable; public String newReleaseVersion; diff --git a/app/src/main/java/org/ranobe/ranobe/sources/en/LightNovelBtt.java b/app/src/main/java/org/ranobe/ranobe/sources/en/LightNovelBtt.java index b3154c9..dab92bc 100644 --- a/app/src/main/java/org/ranobe/ranobe/sources/en/LightNovelBtt.java +++ b/app/src/main/java/org/ranobe/ranobe/sources/en/LightNovelBtt.java @@ -1,7 +1,5 @@ package org.ranobe.ranobe.sources.en; -import android.util.Log; - import org.jsoup.Jsoup; import org.jsoup.nodes.Element; import org.ranobe.ranobe.models.Chapter; diff --git a/app/src/main/java/org/ranobe/ranobe/sources/en/Neovel.java b/app/src/main/java/org/ranobe/ranobe/sources/en/Neovel.java index 307ac9a..f06d4ca 100644 --- a/app/src/main/java/org/ranobe/ranobe/sources/en/Neovel.java +++ b/app/src/main/java/org/ranobe/ranobe/sources/en/Neovel.java @@ -44,16 +44,19 @@ private String getCoverImage(String bookId) { private String getStatus(int completion) { switch (completion) { - case 1: return "Ongoing"; - case 3: return "Completed"; - default: return "N.A."; + case 1: + return "Ongoing"; + case 3: + return "Completed"; + default: + return "N.A."; } } private int getYear(String date) { Pattern pattern = Pattern.compile("/\\d{4}/gm"); Matcher m = pattern.matcher(date); - if(m.find()) { + if (m.find()) { return Integer.parseInt(m.group()); } return 0; @@ -61,7 +64,7 @@ private int getYear(String date) { private List jsonArrayToString(JSONArray arr) throws JSONException { List values = new ArrayList<>(); - for(int i = 0; i < arr.length(); i++) { + for (int i = 0; i < arr.length(); i++) { values.add(arr.getString(0)); } return values; @@ -74,7 +77,7 @@ private String encodeKeyword(String keyword) { @Override public List novels(int page) throws Exception { - String web = BASE_URL +"/V2/books/search?language=EN&filter=0&name=&sort=6&page=".concat(String.valueOf(page)) + "&onlyOffline=true&genreIds=0&genreCombining=0&tagIds=0&tagCombining=0&minChapterCount=0&maxChapterCount=9999&completion=5&onlyPremium=false&blacklistedTagIds=&onlyMature=false"; + String web = BASE_URL + "/V2/books/search?language=EN&filter=0&name=&sort=6&page=".concat(String.valueOf(page)) + "&onlyOffline=true&genreIds=0&genreCombining=0&tagIds=0&tagCombining=0&minChapterCount=0&maxChapterCount=9999&completion=5&onlyPremium=false&blacklistedTagIds=&onlyMature=false"; return parseNovels(web); } @@ -82,7 +85,7 @@ private List parseNovels(String web) throws Exception { List items = new ArrayList<>(); JSONArray data = new JSONArray(HttpClient.GET(web, new HashMap<>())); - for(int i = 0; i < data.length(); i++) { + for (int i = 0; i < data.length(); i++) { JSONObject d = data.getJSONObject(i); String url = BASE_URL + "/" + d.getString("id"); @@ -122,7 +125,7 @@ public List chapters(Novel novel) throws Exception { String url = String.format("https://neovel.io/V5/chapters?bookId=%s&language=EN", bookId); JSONArray data = new JSONArray(HttpClient.GET(url, new HashMap<>())); - for(int i = 0; i < data.length(); i++) { + for (int i = 0; i < data.length(); i++) { JSONObject o = data.getJSONObject(i); String u = BASE_URL + "/chapter/" + o.getString("chapterId"); @@ -145,7 +148,7 @@ public Chapter chapter(Chapter chapter) throws Exception { Element doc = Jsoup.parse(data.getString("chapterContent")); List paras = new ArrayList<>(); - for(String bits: doc.wholeText().split("\n")){ + for (String bits : doc.wholeText().split("\n")) { String text = bits.trim(); if (text.length() > 0) { paras.add(text); @@ -162,7 +165,7 @@ public List search(Filter filters, int page) throws Exception { if (filters.hashKeyword()) { String encodedKeyword = encodeKeyword(filters.getKeyword()).trim(); - String web = BASE_URL +"/V2/books/search?language=EN&filter=0&name=" + encodedKeyword + "&sort=6&page=".concat(String.valueOf(page - 1)) + "&onlyOffline=true&genreIds=0&genreCombining=0&tagIds=0&tagCombining=0&minChapterCount=0&maxChapterCount=9999&completion=5&onlyPremium=false&blacklistedTagIds=&onlyMature=false"; + String web = BASE_URL + "/V2/books/search?language=EN&filter=0&name=" + encodedKeyword + "&sort=6&page=".concat(String.valueOf(page - 1)) + "&onlyOffline=true&genreIds=0&genreCombining=0&tagIds=0&tagCombining=0&minChapterCount=0&maxChapterCount=9999&completion=5&onlyPremium=false&blacklistedTagIds=&onlyMature=false"; return parseNovels(web); } diff --git a/app/src/main/java/org/ranobe/ranobe/sources/en/Ranobe.java b/app/src/main/java/org/ranobe/ranobe/sources/en/Ranobe.java index 1274213..5363a74 100644 --- a/app/src/main/java/org/ranobe/ranobe/sources/en/Ranobe.java +++ b/app/src/main/java/org/ranobe/ranobe/sources/en/Ranobe.java @@ -12,7 +12,6 @@ import org.ranobe.ranobe.util.NumberUtils; import org.ranobe.ranobe.util.SourceUtils; -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -54,6 +53,7 @@ public List novels(int page) throws Exception { return items; } + @Override public Novel details(Novel novel) throws Exception { Element doc = Jsoup.parse(HttpClient.GET(novel.url, new HashMap<>())); diff --git a/app/src/main/java/org/ranobe/ranobe/ui/browse/Browse.java b/app/src/main/java/org/ranobe/ranobe/ui/browse/Browse.java index 92ed549..d958d04 100644 --- a/app/src/main/java/org/ranobe/ranobe/ui/browse/Browse.java +++ b/app/src/main/java/org/ranobe/ranobe/ui/browse/Browse.java @@ -1,7 +1,6 @@ package org.ranobe.ranobe.ui.browse; import android.os.Bundle; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/app/src/main/java/org/ranobe/ranobe/ui/browse/viewmodel/BrowseViewModel.java b/app/src/main/java/org/ranobe/ranobe/ui/browse/viewmodel/BrowseViewModel.java index 68e7a36..dfc3e2e 100644 --- a/app/src/main/java/org/ranobe/ranobe/ui/browse/viewmodel/BrowseViewModel.java +++ b/app/src/main/java/org/ranobe/ranobe/ui/browse/viewmodel/BrowseViewModel.java @@ -1,11 +1,8 @@ package org.ranobe.ranobe.ui.browse.viewmodel; -import android.util.Log; - import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.ViewModel; -import org.ranobe.ranobe.config.Ranobe; import org.ranobe.ranobe.models.Novel; import org.ranobe.ranobe.network.repository.Repository; diff --git a/app/src/main/java/org/ranobe/ranobe/ui/chapters/adapter/ChapterAdapter.java b/app/src/main/java/org/ranobe/ranobe/ui/chapters/adapter/ChapterAdapter.java index 71d5f68..108320e 100644 --- a/app/src/main/java/org/ranobe/ranobe/ui/chapters/adapter/ChapterAdapter.java +++ b/app/src/main/java/org/ranobe/ranobe/ui/chapters/adapter/ChapterAdapter.java @@ -14,8 +14,8 @@ public class ChapterAdapter extends RecyclerView.Adapter { private final List items; - private List readingList; private final OnChapterItemClickListener listener; + private List readingList; public ChapterAdapter(List items, OnChapterItemClickListener listener) { this.items = items; diff --git a/app/src/main/java/org/ranobe/ranobe/ui/chapters/viewmodel/ChaptersViewModel.java b/app/src/main/java/org/ranobe/ranobe/ui/chapters/viewmodel/ChaptersViewModel.java index 6045fe9..6586419 100644 --- a/app/src/main/java/org/ranobe/ranobe/ui/chapters/viewmodel/ChaptersViewModel.java +++ b/app/src/main/java/org/ranobe/ranobe/ui/chapters/viewmodel/ChaptersViewModel.java @@ -3,7 +3,6 @@ import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.ViewModel; -import org.ranobe.ranobe.models.Chapter; import org.ranobe.ranobe.models.Chapter; import org.ranobe.ranobe.models.Novel; import org.ranobe.ranobe.network.repository.Repository; @@ -12,6 +11,7 @@ public class ChaptersViewModel extends ViewModel { private MutableLiveData error = new MutableLiveData<>(); + public MutableLiveData getError() { return error = new MutableLiveData<>(); } diff --git a/app/src/main/java/org/ranobe/ranobe/ui/details/Details.java b/app/src/main/java/org/ranobe/ranobe/ui/details/Details.java index 283609b..0824aa2 100644 --- a/app/src/main/java/org/ranobe/ranobe/ui/details/Details.java +++ b/app/src/main/java/org/ranobe/ranobe/ui/details/Details.java @@ -74,7 +74,7 @@ private void setUpError(String error) { } private void navigateToChapterList() { - if(novel == null) return; + if (novel == null) return; Bundle bundle = new Bundle(); bundle.putParcelable(Ranobe.KEY_NOVEL, novel); Chapters chapters = new Chapters(); @@ -117,7 +117,7 @@ private void addChips(List genres) { private void addToLibrary(Novel novel) { if (novel == null) return; - RanobeDatabase.databaseExecutor.execute( () -> RanobeDatabase.database().novels().save(novel)); + RanobeDatabase.databaseExecutor.execute(() -> RanobeDatabase.database().novels().save(novel)); Snackbar.make(binding.getRoot(), "Added novel to library", Snackbar.LENGTH_SHORT).show(); } } diff --git a/app/src/main/java/org/ranobe/ranobe/ui/details/viewmodel/DetailsViewModel.java b/app/src/main/java/org/ranobe/ranobe/ui/details/viewmodel/DetailsViewModel.java index d91070d..9dfcb5a 100644 --- a/app/src/main/java/org/ranobe/ranobe/ui/details/viewmodel/DetailsViewModel.java +++ b/app/src/main/java/org/ranobe/ranobe/ui/details/viewmodel/DetailsViewModel.java @@ -8,9 +8,11 @@ public class DetailsViewModel extends ViewModel { private MutableLiveData error = new MutableLiveData<>(); + public MutableLiveData getError() { return error = new MutableLiveData<>(); } + public MutableLiveData details(Novel novel) { MutableLiveData details = new MutableLiveData<>(); new Repository().details(novel, new Repository.Callback() { diff --git a/app/src/main/java/org/ranobe/ranobe/ui/library/Library.java b/app/src/main/java/org/ranobe/ranobe/ui/library/Library.java index 01bc601..f2803c2 100644 --- a/app/src/main/java/org/ranobe/ranobe/ui/library/Library.java +++ b/app/src/main/java/org/ranobe/ranobe/ui/library/Library.java @@ -61,7 +61,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat private void setNovels(List novels) { binding.progress.hide(); - if (novels.size() == 0) { + if (novels.size() == 0) { showNoNovels(); return; } diff --git a/app/src/main/java/org/ranobe/ranobe/ui/reader/viewmodel/ReaderViewModel.java b/app/src/main/java/org/ranobe/ranobe/ui/reader/viewmodel/ReaderViewModel.java index 77bc826..8d696f9 100644 --- a/app/src/main/java/org/ranobe/ranobe/ui/reader/viewmodel/ReaderViewModel.java +++ b/app/src/main/java/org/ranobe/ranobe/ui/reader/viewmodel/ReaderViewModel.java @@ -3,7 +3,6 @@ import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.ViewModel; -import org.ranobe.ranobe.models.Chapter; import org.ranobe.ranobe.models.Chapter; import org.ranobe.ranobe.models.Novel; import org.ranobe.ranobe.network.repository.Repository; diff --git a/app/src/main/java/org/ranobe/ranobe/ui/search/viewmodel/SearchViewModel.java b/app/src/main/java/org/ranobe/ranobe/ui/search/viewmodel/SearchViewModel.java index c78a71c..852226f 100644 --- a/app/src/main/java/org/ranobe/ranobe/ui/search/viewmodel/SearchViewModel.java +++ b/app/src/main/java/org/ranobe/ranobe/ui/search/viewmodel/SearchViewModel.java @@ -12,9 +12,9 @@ import java.util.List; public class SearchViewModel extends ViewModel { + private final MutableLiveData>> results = new MutableLiveData<>(); private MutableLiveData error = new MutableLiveData<>(); private Filter filter = new Filter(); - private final MutableLiveData>> results = new MutableLiveData<>(); public MutableLiveData getError() { return error = new MutableLiveData<>(); @@ -30,7 +30,7 @@ public MutableLiveData>> search(List>() { @Override public void onComplete(List result) { diff --git a/app/src/main/java/org/ranobe/ranobe/ui/settings/viewmodel/SettingsViewModel.java b/app/src/main/java/org/ranobe/ranobe/ui/settings/viewmodel/SettingsViewModel.java index a0a3080..6d711d3 100644 --- a/app/src/main/java/org/ranobe/ranobe/ui/settings/viewmodel/SettingsViewModel.java +++ b/app/src/main/java/org/ranobe/ranobe/ui/settings/viewmodel/SettingsViewModel.java @@ -1,4 +1,5 @@ package org.ranobe.ranobe.ui.settings.viewmodel; + import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.ViewModel; diff --git a/app/src/main/java/org/ranobe/ranobe/ui/views/RecyclerSwipeHelper.java b/app/src/main/java/org/ranobe/ranobe/ui/views/RecyclerSwipeHelper.java index f674d2f..d71bd88 100644 --- a/app/src/main/java/org/ranobe/ranobe/ui/views/RecyclerSwipeHelper.java +++ b/app/src/main/java/org/ranobe/ranobe/ui/views/RecyclerSwipeHelper.java @@ -37,7 +37,7 @@ public abstract class RecyclerSwipeHelper extends SimpleCallback { public RecyclerSwipeHelper(@ColorInt int swipeRightColor, @ColorInt int swipeLeftColor, @DrawableRes int swipeRightIconResource, @DrawableRes int swipeLeftIconResource, Context context) { - super(0, LEFT|RIGHT); + super(0, LEFT | RIGHT); clearPaint = new Paint(); clearPaint.setXfermode(new PorterDuffXfermode(CLEAR)); @@ -75,7 +75,7 @@ public void onChildDrawOver(@NonNull Canvas c, @NonNull RecyclerView recyclerVie return; } - if(dX < 0) { + if (dX < 0) { background.setColor(swipeLeftColor); background.setBounds((int) (itemView.getRight() + dX), itemView.getTop(), itemView.getRight(), itemView.getBottom()); background.draw(c); @@ -86,15 +86,14 @@ public void onChildDrawOver(@NonNull Canvas c, @NonNull RecyclerView recyclerVie int itemRight = itemView.getRight() - itemMargin; int itemBottom = itemTop + intrinsicHeight; - int alpha = ((int)((-itemView.getTranslationX()/itemView.getWidth())*510)); - if(alpha > 255) alpha = 255; + int alpha = ((int) ((-itemView.getTranslationX() / itemView.getWidth()) * 510)); + if (alpha > 255) alpha = 255; swipeLeftIcon.setAlpha(alpha); swipeLeftIcon.setBounds(itemLeft, itemTop, itemRight, itemBottom); swipeLeftIcon.draw(c); - } - else { + } else { background.setColor(swipeRightColor); background.setBounds((int) (itemView.getLeft() + dX), itemView.getTop(), itemView.getLeft(), itemView.getBottom()); background.draw(c); @@ -105,8 +104,8 @@ public void onChildDrawOver(@NonNull Canvas c, @NonNull RecyclerView recyclerVie int itemRight = itemView.getLeft() + itemMargin + intrinsicWidth; int itemBottom = itemTop + intrinsicHeight; - int alpha = ((int)((itemView.getTranslationX()/itemView.getWidth())*510)); - if(alpha > 255) alpha = 255; + int alpha = ((int) ((itemView.getTranslationX() / itemView.getWidth()) * 510)); + if (alpha > 255) alpha = 255; swipeRightIcon.setAlpha(alpha); swipeRightIcon.setBounds(itemLeft, itemTop, itemRight, itemBottom); @@ -122,6 +121,6 @@ public int getSwipeDirs(@NonNull RecyclerView recyclerView, @NonNull RecyclerVie } private void clearCanvas(Canvas c, float left, float top, float right, float bottom) { - if(c != null) c.drawRect(left, top, right, bottom, clearPaint); + if (c != null) c.drawRect(left, top, right, bottom, clearPaint); } } diff --git a/app/src/main/java/org/ranobe/ranobe/util/Version.java b/app/src/main/java/org/ranobe/ranobe/util/Version.java index b9a5c40..fbba356 100644 --- a/app/src/main/java/org/ranobe/ranobe/util/Version.java +++ b/app/src/main/java/org/ranobe/ranobe/util/Version.java @@ -6,14 +6,10 @@ public class Version implements Comparable { private final String version; - public final String get() { - return this.version; - } - public Version(String version) { - if(version == null) + if (version == null) throw new IllegalArgumentException("Version can not be null"); - if(!version.matches("[0-9]+(\\.[0-9]+)*")) + if (!version.matches("[0-9]+(\\.[0-9]+)*")) throw new IllegalArgumentException("Invalid version format"); this.version = version; } @@ -24,20 +20,25 @@ public static String extractVersionNumber(String input) { return match.find() ? match.group() : null; } - @Override public int compareTo(Version that) { - if(that == null) + public final String get() { + return this.version; + } + + @Override + public int compareTo(Version that) { + if (that == null) return 1; String[] thisParts = this.get().split("\\."); String[] thatParts = that.get().split("\\."); int length = Math.max(thisParts.length, thatParts.length); - for(int i = 0; i < length; i++) { + for (int i = 0; i < length; i++) { int thisPart = i < thisParts.length ? Integer.parseInt(thisParts[i]) : 0; int thatPart = i < thatParts.length ? Integer.parseInt(thatParts[i]) : 0; - if(thisPart < thatPart) + if (thisPart < thatPart) return -1; - if(thisPart > thatPart) + if (thisPart > thatPart) return 1; } return 0; diff --git a/app/src/main/res/drawable/ic_library.xml b/app/src/main/res/drawable/ic_library.xml index 3a85b9f..13366a8 100644 --- a/app/src/main/res/drawable/ic_library.xml +++ b/app/src/main/res/drawable/ic_library.xml @@ -1,5 +1,10 @@ - - + + diff --git a/app/src/main/res/drawable/ic_mark_read.xml b/app/src/main/res/drawable/ic_mark_read.xml index 94b4dcd..6596199 100644 --- a/app/src/main/res/drawable/ic_mark_read.xml +++ b/app/src/main/res/drawable/ic_mark_read.xml @@ -1,5 +1,10 @@ - - + + diff --git a/app/src/main/res/drawable/ic_mark_unread.xml b/app/src/main/res/drawable/ic_mark_unread.xml index f0abc2d..baf15be 100644 --- a/app/src/main/res/drawable/ic_mark_unread.xml +++ b/app/src/main/res/drawable/ic_mark_unread.xml @@ -1,5 +1,10 @@ - - + + diff --git a/app/src/main/res/layout/fragment_chapters.xml b/app/src/main/res/layout/fragment_chapters.xml index 84f5d30..04e492a 100644 --- a/app/src/main/res/layout/fragment_chapters.xml +++ b/app/src/main/res/layout/fragment_chapters.xml @@ -37,11 +37,11 @@ diff --git a/app/src/main/res/layout/fragment_details.xml b/app/src/main/res/layout/fragment_details.xml index ff28bbe..87fc090 100644 --- a/app/src/main/res/layout/fragment_details.xml +++ b/app/src/main/res/layout/fragment_details.xml @@ -123,11 +123,11 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/summary" - android:layout_toStartOf="@id/read_chapter" android:layout_marginStart="10dp" android:layout_marginTop="10dp" android:layout_marginEnd="10dp" android:layout_marginBottom="10dp" + android:layout_toStartOf="@id/read_chapter" android:text="@string/add_to_lib_info" />