From 2388e48c3a3ce771edb5c46839936d0fee9cc23b Mon Sep 17 00:00:00 2001 From: Mehul Mittal Date: Sat, 4 Aug 2018 19:51:57 +0530 Subject: [PATCH 1/7] Add StartedAt and CompletedAt options in Edit Entry (#68) * WIP - Add StartedAt in Edit Media Entry Dialog * WIP - Add CompletedAT in Edit Media Entry Dialog, and some uniform naming changes for StartedAt * Tried to implement DatePicker, crashes on tapping Update * Update CustomSeriesAnimeManage.java original layout * Rewrote logic and layout for handling of StartedAt and CompletedAt * Added StartedAt and CompletedAt for editing Manga entry * Fixed DatePicker setting a decremented value of month. * Use an instance of FuzzyDate instead of FuzzyDateConverter * Remove custom log message for temporary use * Remove unused imports --- .../view/widget/CustomSeriesAnimeManage.java | 13 +- .../view/widget/CustomSeriesMangaManage.java | 4 + .../custom/view/widget/FuzzyDateWidget.java | 89 ++++++++++ .../model/entity/anilist/MediaList.java | 8 + .../model/entity/anilist/meta/FuzzyDate.java | 6 + .../java/com/mxt/anitrend/util/KeyUtil.java | 2 + .../com/mxt/anitrend/util/MediaListUtil.java | 2 + .../main/res/layout/custom_action_anime.xml | 166 +++++++++++------- .../main/res/layout/custom_action_manga.xml | 127 +++++++++----- app/src/main/res/layout/widget_fuzzy_date.xml | 71 ++++++++ app/src/main/res/values/strings.xml | 2 + 11 files changed, 385 insertions(+), 105 deletions(-) create mode 100644 app/src/main/java/com/mxt/anitrend/base/custom/view/widget/FuzzyDateWidget.java create mode 100644 app/src/main/res/layout/widget_fuzzy_date.xml diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesAnimeManage.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesAnimeManage.java index 7b9f5841d..e050571cc 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesAnimeManage.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesAnimeManage.java @@ -55,6 +55,7 @@ public void onInit() { /** * Saves the current views states into the model * and returns a bundle of the params + * * @see com.mxt.anitrend.util.MediaListUtil */ @Override @@ -62,6 +63,8 @@ public Bundle persistChanges() { model.setProgress(binding.diaCurrentProgress.getProgressCurrent()); model.setRepeat(binding.diaCurrentRewatch.getProgressCurrent()); model.setScore(binding.diaCurrentScore.getProgressCurrent()); + model.setStartedAt(binding.diaCurrentStartedAt.getDate()); + model.setCompletedAt(binding.diaCurrentCompletedAt.getDate()); model.setHidden(binding.diaCurrentPrivacy.isChecked()); model.setNotes(binding.diaCurrentNotes.getFormattedText()); model.setStatus(KeyUtil.MediaListStatus[binding.diaCurrentStatus.getSelectedItemPosition()]); @@ -83,19 +86,21 @@ protected void bindFields() { // Apply the adapter to the spinner binding.diaCurrentStatus.setAdapter(adapter); - if(!TextUtils.isEmpty(model.getStatus())) + if (!TextUtils.isEmpty(model.getStatus())) binding.diaCurrentStatus.setSelection(CompatUtil.constructListFrom(KeyUtil.MediaListStatus).indexOf(model.getStatus())); else binding.diaCurrentStatus.setSelection(CompatUtil.constructListFrom(KeyUtil.MediaListStatus).indexOf(KeyUtil.PLANNING)); binding.diaCurrentPrivacy.setChecked(model.isHidden()); - if(model.getMedia().getEpisodes() > 0) + if (model.getMedia().getEpisodes() > 0) binding.diaCurrentProgress.setProgressMaximum(model.getMedia().getEpisodes()); binding.diaCurrentScore.setProgressMaximum(100); binding.diaCurrentScore.setProgressCurrent((int)model.getScore()); binding.diaCurrentProgress.setProgressCurrent(model.getProgress()); binding.diaCurrentRewatch.setProgressCurrent(model.getRepeat()); + binding.diaCurrentStartedAt.setDate(model.getStartedAt()); + binding.diaCurrentCompletedAt.setDate(model.getCompletedAt()); binding.diaCurrentStatus.setOnItemSelectedListener(this); } @@ -106,7 +111,7 @@ protected void bindFields() { @Override public void onViewRecycled() { super.onViewRecycled(); - if(binding != null) + if (binding != null) binding.unbind(); } @@ -141,4 +146,4 @@ public void onItemSelected(AdapterView adapterView, View view, int i, long l) public void onNothingSelected(AdapterView adapterView) { } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesMangaManage.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesMangaManage.java index 0b58cf099..332567dea 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesMangaManage.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesMangaManage.java @@ -63,6 +63,8 @@ public Bundle persistChanges() { model.setRepeat(binding.diaCurrentReread.getProgressCurrent()); model.setProgressVolumes(binding.diaCurrentVolumes.getProgressCurrent()); model.setScore(binding.diaCurrentScore.getProgressCurrent()); + model.setStartedAt(binding.diaCurrentStartedAt.getDate()); + model.setCompletedAt(binding.diaCurrentCompletedAt.getDate()); model.setHidden(binding.diaCurrentPrivacy.isChecked()); model.setNotes(binding.diaCurrentNotes.getFormattedText()); model.setStatus(KeyUtil.MediaListStatus[binding.diaCurrentStatus.getSelectedItemPosition()]); @@ -101,6 +103,8 @@ protected void bindFields() { binding.diaCurrentChapters.setProgressCurrent(model.getProgress()); binding.diaCurrentVolumes.setProgressCurrent(model.getProgressVolumes()); binding.diaCurrentReread.setProgressCurrent(model.getRepeat()); + binding.diaCurrentStartedAt.setDate(model.getStartedAt()); + binding.diaCurrentCompletedAt.setDate(model.getCompletedAt()); binding.diaCurrentStatus.setOnItemSelectedListener(this); } diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/FuzzyDateWidget.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/FuzzyDateWidget.java new file mode 100644 index 000000000..16ba7410c --- /dev/null +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/FuzzyDateWidget.java @@ -0,0 +1,89 @@ +package com.mxt.anitrend.base.custom.view.widget; + +import android.annotation.TargetApi; +import android.app.DatePickerDialog; +import android.content.Context; +import android.os.Build; +import android.support.annotation.Nullable; +import android.util.AttributeSet; +import android.view.View; +import android.widget.DatePicker; +import android.widget.FrameLayout; + +import com.mxt.anitrend.base.interfaces.view.CustomView; +import com.mxt.anitrend.databinding.WidgetFuzzyDateBinding; +import com.mxt.anitrend.model.entity.anilist.meta.FuzzyDate; +import com.mxt.anitrend.util.CompatUtil; + +import java.util.Calendar; + +public class FuzzyDateWidget extends FrameLayout implements CustomView, View.OnClickListener, DatePickerDialog.OnDateSetListener{ + + private WidgetFuzzyDateBinding binding; + + private FuzzyDate fuzzyDate; + + public FuzzyDateWidget(Context context) { + super(context); + onInit(); + } + + public FuzzyDateWidget(Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + onInit(); + } + + public FuzzyDateWidget(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + onInit(); + } + + @TargetApi(Build.VERSION_CODES.LOLLIPOP) + public FuzzyDateWidget(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + onInit(); + } + + @Override + public void onInit() { + binding = WidgetFuzzyDateBinding.inflate(CompatUtil.getLayoutInflater(getContext()),this, true); + binding.setOnClick(this); + } + + public void setDate(FuzzyDate fuzzyDate) { + this.fuzzyDate = fuzzyDate; + updateDate(); + } + + private void updateDate(){ + binding.fuzzyDateDay.setText(String.valueOf(fuzzyDate.getDay())); + binding.fuzzyDateMonth.setText(String.valueOf(fuzzyDate.getMonth())); + binding.fuzzyDateYear.setText(String.valueOf(fuzzyDate.getYear())); + } + + public FuzzyDate getDate() { + return fuzzyDate; + } + + @Override + public void onViewRecycled() { + + } + + @Override + public void onClick(View v) { + Calendar myCalendar = Calendar.getInstance(); + DatePickerDialog dialog = new DatePickerDialog(getContext(), this, myCalendar + .get(Calendar.YEAR), myCalendar.get(Calendar.MONTH), + myCalendar.get(Calendar.DAY_OF_MONTH)); + dialog.show(); + } + + @Override + public void onDateSet(DatePicker datePicker, int y, int m, int d) { + fuzzyDate.setDate(d, m+1, y); + updateDate(); + } +} + + diff --git a/app/src/main/java/com/mxt/anitrend/model/entity/anilist/MediaList.java b/app/src/main/java/com/mxt/anitrend/model/entity/anilist/MediaList.java index 44a2b044c..62c7b628f 100644 --- a/app/src/main/java/com/mxt/anitrend/model/entity/anilist/MediaList.java +++ b/app/src/main/java/com/mxt/anitrend/model/entity/anilist/MediaList.java @@ -232,6 +232,14 @@ public void setCustomLists(List customLists) { this.customLists = customLists; } + public void setStartedAt(FuzzyDate startedAt) { + this.startedAt = startedAt; + } + + public void setCompletedAt(FuzzyDate completedAt) { + this.completedAt = completedAt; + } + @Override public boolean equals(Object obj) { if(obj instanceof MediaList) diff --git a/app/src/main/java/com/mxt/anitrend/model/entity/anilist/meta/FuzzyDate.java b/app/src/main/java/com/mxt/anitrend/model/entity/anilist/meta/FuzzyDate.java index f2ab0111d..48763da07 100644 --- a/app/src/main/java/com/mxt/anitrend/model/entity/anilist/meta/FuzzyDate.java +++ b/app/src/main/java/com/mxt/anitrend/model/entity/anilist/meta/FuzzyDate.java @@ -57,6 +57,12 @@ public int getYear() { return year; } + public void setDate(int day, int month, int year) { + this.day = day; + this.month = month; + this.year = year; + } + public boolean isValidDate() { return day != 0 || month != 0 || year != 0; } diff --git a/app/src/main/java/com/mxt/anitrend/util/KeyUtil.java b/app/src/main/java/com/mxt/anitrend/util/KeyUtil.java index 8d810431d..89c651802 100644 --- a/app/src/main/java/com/mxt/anitrend/util/KeyUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/KeyUtil.java @@ -73,6 +73,8 @@ public interface KeyUtil { String arg_listHiddenFromStatusLists = "hiddenFromStatusLists"; String arg_listAdvancedScore = "advancedScores"; String arg_listCustom = "customLists"; + String arg_startedAt = "startedAt"; + String arg_completedAt = "completedAt"; /** Media Browse Keys */ String arg_startDateLike = "startDateLike"; diff --git a/app/src/main/java/com/mxt/anitrend/util/MediaListUtil.java b/app/src/main/java/com/mxt/anitrend/util/MediaListUtil.java index 214b27ad4..bafe0e763 100644 --- a/app/src/main/java/com/mxt/anitrend/util/MediaListUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/MediaListUtil.java @@ -25,6 +25,8 @@ public static Bundle getMediaListParams(@NonNull MediaList model) { queryContainer.putVariable(KeyUtil.arg_listPrivate, model.isHidden()); queryContainer.putVariable(KeyUtil.arg_listPriority, model.getPriority()); queryContainer.putVariable(KeyUtil.arg_listHiddenFromStatusLists, model.isHiddenFromStatusLists()); + queryContainer.putVariable(KeyUtil.arg_startedAt, model.getStartedAt()); + queryContainer.putVariable(KeyUtil.arg_completedAt, model.getCompletedAt()); if(model.getAdvancedScores() != null) queryContainer.putVariable(KeyUtil.arg_listAdvancedScore, model.getAdvancedScores()); diff --git a/app/src/main/res/layout/custom_action_anime.xml b/app/src/main/res/layout/custom_action_anime.xml index b8f0b741b..5356c320a 100644 --- a/app/src/main/res/layout/custom_action_anime.xml +++ b/app/src/main/res/layout/custom_action_anime.xml @@ -1,33 +1,35 @@ - - + + + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + android:layout_height="wrap_content" + android:layout_gravity="center_vertical|start" + android:text="@string/dialog_title_status" /> + android:layout_height="wrap_content" + android:layout_gravity="center_vertical|end" /> @@ -40,16 +42,16 @@ android:layout_height="wrap_content"> + android:layout_height="wrap_content" + android:layout_gravity="center_vertical|start" + android:text="@string/dialog_title_score" /> + android:layout_height="wrap_content" + android:layout_gravity="center_vertical|end" /> @@ -62,16 +64,16 @@ android:layout_height="wrap_content"> + android:layout_height="wrap_content" + android:layout_gravity="center_vertical|start" + android:text="@string/dialog_title_episodes" /> + android:layout_height="wrap_content" + android:layout_gravity="center_vertical|end" /> @@ -79,71 +81,115 @@ android:layout_width="match_parent" android:layout_height="@dimen/xl_margin" /> - + - + - + - + - + + + + android:layout_height="wrap_content" + android:layout_gravity="center_vertical|end" + android:clickable="true" /> + - + + + + + + + + + + + + + + + + android:layout_height="wrap_content" + android:layout_gravity="center_vertical|end" /> - + - + - + - + + android:background="@drawable/dashed_background" + android:layerType="software" /> - + \ No newline at end of file diff --git a/app/src/main/res/layout/custom_action_manga.xml b/app/src/main/res/layout/custom_action_manga.xml index bbc5ec222..fc094a843 100644 --- a/app/src/main/res/layout/custom_action_manga.xml +++ b/app/src/main/res/layout/custom_action_manga.xml @@ -1,33 +1,35 @@ - - + + + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + android:layout_height="wrap_content" + android:layout_gravity="center_vertical|start" + android:text="@string/dialog_title_status" /> + android:layout_height="wrap_content" + android:layout_gravity="center_vertical|end" /> @@ -40,16 +42,16 @@ android:layout_height="wrap_content"> + android:layout_height="wrap_content" + android:layout_gravity="center_vertical|start" + android:text="@string/dialog_title_score" /> + android:layout_height="wrap_content" + android:layout_gravity="center_vertical|end" /> @@ -62,16 +64,16 @@ android:layout_height="wrap_content"> + android:layout_height="wrap_content" + android:layout_gravity="center_vertical|start" + android:text="@string/dialog_title_chapters_read" /> + android:layout_height="wrap_content" + android:layout_gravity="center_vertical|end" /> @@ -84,16 +86,16 @@ android:layout_height="wrap_content"> + android:layout_height="wrap_content" + android:layout_gravity="center_vertical|start" + android:text="@string/dialog_title_volumes_read" /> + android:layout_height="wrap_content" + android:layout_gravity="center_vertical|end" /> @@ -106,17 +108,38 @@ android:layout_height="wrap_content"> + android:layout_height="wrap_content" + android:layout_gravity="center_vertical|start" + android:text="@string/dialog_title_reread" /> + android:layout_height="wrap_content" + android:layout_gravity="center_vertical|end" /> + + + + + + + + + + + + + + + + + + android:layout_height="wrap_content" + android:layout_gravity="center_vertical|start" + android:text="@string/dialog_title_private" /> + android:layout_height="wrap_content" + android:layout_gravity="center_vertical|end" /> @@ -151,21 +196,21 @@ + android:text="@{model.notes}" + android:textSize="@dimen/subtitle_text_size" /> + android:background="@drawable/dashed_background" + android:layerType="software" /> - + \ No newline at end of file diff --git a/app/src/main/res/layout/widget_fuzzy_date.xml b/app/src/main/res/layout/widget_fuzzy_date.xml new file mode 100644 index 000000000..8a79c7a55 --- /dev/null +++ b/app/src/main/res/layout/widget_fuzzy_date.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 46a85d53e..51a1252be 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -994,4 +994,6 @@ Usage Analytics Enable Usage Analytics (require app restart) Disable Usage Analytics (require app restart) + Start Date + Finish Date From 44a19c5e9f8997aff118aece931573ea39e59f1e Mon Sep 17 00:00:00 2001 From: Maxwell Date: Thu, 9 Aug 2018 14:45:37 +0200 Subject: [PATCH 2/7] Updated Core Classes & Gradle Plugins - Updated .github template files - Updated application class, mainly analytics configuration - Cleaned up some other random files (no breaking changes) --- .../issue_template.md => ISSUE_TEMPLATE.md} | 15 +++++- .github/PULL_REQUEST_TEMPLATE.md | 46 +++++++++++++++++++ .../pull_request_template.md | 28 ----------- app/.travic-ci/secrets | 4 +- app/src/main/java/com/mxt/anitrend/App.java | 12 ++--- .../base/custom/activity/ActivityBase.java | 2 +- build.gradle | 6 +-- 7 files changed, 70 insertions(+), 43 deletions(-) rename .github/{ISSUE_TEMPLATE/issue_template.md => ISSUE_TEMPLATE.md} (63%) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/PULL_REQUEST_TEMPLATE/pull_request_template.md diff --git a/.github/ISSUE_TEMPLATE/issue_template.md b/.github/ISSUE_TEMPLATE.md similarity index 63% rename from .github/ISSUE_TEMPLATE/issue_template.md rename to .github/ISSUE_TEMPLATE.md index b322dfdd5..0a9922e71 100644 --- a/.github/ISSUE_TEMPLATE/issue_template.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,5 +1,16 @@ - +# AniTrend Issue +Before opening a new issue, please take a moment to review our [**community guidelines**](https://github.com/AniTrend/anitrend-app/blob/master/CONTRIBUTING.md) to make the contribution process easy and effective for everyone involved. + +**Before opening a new issue, you may find an answer in already closed issues**: +https://github.com/AniTrend/anitrend-app/issues?q=is%3Aissue+is%3Aclosed + + +## Issue Type + + +- [ ] Bug +- [ ] Feature # Expected Behavior @@ -36,5 +47,5 @@ Please provide any relevant information about your device. This is important in * Phone Brand: ## Failure Logs + -Please include any relevant log snippets or files here, if any otherwise remove this heading section diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..8be563339 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,46 @@ +# AniTrend Pull Request + +Thank you for contributing! Please take a moment to review our [**contributing guidelines**](https://github.com/AniTrend/anitrend-app/blob/master/CONTRIBUTING.md) +to make the process easy and effective for everyone involved. + +**Please open an issue** before embarking on any significant pull request, especially those that +add a new library or change existing tests, otherwise you risk spending a lot of time working +on something that might not end up being merged into the project. + +Before opening a pull request, please ensure: + + + +- [ ] You have followed our [**contributing guidelines**](https://github.com/AniTrend/anitrend-app/blob/master/CONTRIBUTING.md) +- [ ] double-check your branch is based on `develop` and targets `develop` +- [ ] Pull request has tests +- [ ] Code is well-commented, linted and follows project conventions +- [ ] Documentation is updated (if necessary) +- [ ] Description explains the issue/use-case resolved +- [ ] I did not commit files that are excluded in the .gitignore file (Happens if you stage files with Android Studio) + + +## Description + + +## Motivation and Context + + + +## How Has This Been Tested? + + + + +## Screenshots (if appropriate): + +## Types of changes + +- [ ] Bug fix (non-breaking change which fixes an issue) +- [ ] New feature (non-breaking change which adds functionality) +- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) + + + +**IMPORTANT**: By submitting a patch, you agree to allow the project +owners to license your work under the terms of the [MIT License](https://github.com/AniTrend/anitrend-app/blob/master/LICENSE.md). \ No newline at end of file diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md deleted file mode 100644 index 3d240bf1a..000000000 --- a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +++ /dev/null @@ -1,28 +0,0 @@ - - -## Description - - -## Motivation and Context - - - -## How Has This Been Tested? - - - - -## Screenshots (if appropriate): - -## Types of changes - -- [ ] Bug fix (non-breaking change which fixes an issue) -- [ ] New feature (non-breaking change which adds functionality) -- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - -## Checklist: - - -- [ ] My code follows the code style of this project. -- [ ] My change requires a change to the documentation. -- [ ] I have updated the documentation accordingly. diff --git a/app/.travic-ci/secrets b/app/.travic-ci/secrets index e725b3445..55c0ef09b 100644 --- a/app/.travic-ci/secrets +++ b/app/.travic-ci/secrets @@ -1,6 +1,6 @@ # Custom gradle properties file API_KEY = "API_KEY" -CLIENT_ID = "CLIENT_ID-9djac" -CLIENT_SECRET = "CLIENT_SECRET" +CLIENT_ID = "CLIENT_ID_FROM_ANILIST" +CLIENT_SECRET = "CLIENT_SECRET_FROM_ANILIST" GIPHY_KEY = "GIPHY_KEY" diff --git a/app/src/main/java/com/mxt/anitrend/App.java b/app/src/main/java/com/mxt/anitrend/App.java index 80925ea9c..1b980865c 100644 --- a/app/src/main/java/com/mxt/anitrend/App.java +++ b/app/src/main/java/com/mxt/anitrend/App.java @@ -3,6 +3,7 @@ import android.app.Application; import android.content.Context; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.crashlytics.android.core.CrashlyticsCore; import com.crashlytics.android.core.CrashlyticsListener; @@ -37,15 +38,12 @@ private void setupBoxStore() { } private void setCrashAnalytics(ApplicationPref pref) { - CrashlyticsCore.Builder builder = new CrashlyticsCore.Builder(); - - if (!BuildConfig.DEBUG) - builder.disabled(pref.isCrashReportsEnabled()); - else - builder.disabled(true); + CrashlyticsCore crashlyticsCore = new CrashlyticsCore.Builder() + .disabled(BuildConfig.DEBUG || !pref.isCrashReportsEnabled()) + .build(); fabric = Fabric.with(new Fabric.Builder(this) - .kits(builder.build()) + .kits(crashlyticsCore) .debuggable(BuildConfig.DEBUG) .appIdentifier(BuildConfig.BUILD_TYPE) .build()); diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/activity/ActivityBase.java b/app/src/main/java/com/mxt/anitrend/base/custom/activity/ActivityBase.java index 175d16520..6b62f2845 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/activity/ActivityBase.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/activity/ActivityBase.java @@ -53,7 +53,7 @@ /** * Created by max on 2017/06/09. - * Activity base + * Activity base */ public abstract class ActivityBase extends AppCompatActivity implements Observer, CommonPresenter.AbstractPresenter

, diff --git a/build.gradle b/build.gradle index f4b8dc4b7..b21ae6d7e 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { retrofit = '2.4.0' supportLibrary = '27.1.1' firebase = '16.0.1' - objectBox = '1.5.0' + objectBox = '2.0.0' architecture = '1.1.1' emojify = '0.1.7' kotlin = '1.2.31' @@ -29,11 +29,11 @@ buildscript { maven { url "http://objectbox.net/beta-repo/" } } dependencies { - classpath 'com.android.tools.build:gradle:3.1.3' + classpath 'com.android.tools.build:gradle:3.1.4' // Google Play Services classpath 'com.google.gms:google-services:4.0.1' // Crash Analytics - classpath 'io.fabric.tools:gradle:1.25.1' + classpath 'io.fabric.tools:gradle:1.25.4' // Object Box classpath "io.objectbox:objectbox-gradle-plugin:${rootProject.objectBox}" } From 42644e44c3a2031dcba0060b03b68420b657b829 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Thu, 9 Aug 2018 14:49:25 +0200 Subject: [PATCH 3/7] Fuzzy Date Widget Fixes & Improvements - Fixed handling of null instance for fuzzy date objects being passed from items not in the users list - Fixed date format by using DateUtil for converting fuzzy date - Removed android:clickable="true" from custom_actioin_* that caused child WidgetFuzzyDate to not get the registered clicks - Redesigned widget_fuzzy_date.xml for the sake of simplicity --- .../custom/view/widget/FuzzyDateWidget.java | 46 ++++++++------ .../model/entity/anilist/meta/FuzzyDate.java | 6 ++ .../java/com/mxt/anitrend/util/DateUtil.java | 16 ++--- .../main/res/layout/custom_action_anime.xml | 6 +- .../main/res/layout/custom_action_manga.xml | 6 +- app/src/main/res/layout/widget_fuzzy_date.xml | 63 ++++++------------- 6 files changed, 66 insertions(+), 77 deletions(-) diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/FuzzyDateWidget.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/FuzzyDateWidget.java index 16ba7410c..55dd0731f 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/FuzzyDateWidget.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/FuzzyDateWidget.java @@ -14,6 +14,7 @@ import com.mxt.anitrend.databinding.WidgetFuzzyDateBinding; import com.mxt.anitrend.model.entity.anilist.meta.FuzzyDate; import com.mxt.anitrend.util.CompatUtil; +import com.mxt.anitrend.util.DateUtil; import java.util.Calendar; @@ -21,7 +22,7 @@ public class FuzzyDateWidget extends FrameLayout implements CustomView, View.OnC private WidgetFuzzyDateBinding binding; - private FuzzyDate fuzzyDate; + private @Nullable FuzzyDate fuzzyDate; public FuzzyDateWidget(Context context) { super(context); @@ -50,18 +51,20 @@ public void onInit() { binding.setOnClick(this); } - public void setDate(FuzzyDate fuzzyDate) { + public void setDate( @Nullable FuzzyDate fuzzyDate) { this.fuzzyDate = fuzzyDate; updateDate(); } - private void updateDate(){ - binding.fuzzyDateDay.setText(String.valueOf(fuzzyDate.getDay())); - binding.fuzzyDateMonth.setText(String.valueOf(fuzzyDate.getMonth())); - binding.fuzzyDateYear.setText(String.valueOf(fuzzyDate.getYear())); + private void updateDate() { + if(fuzzyDate != null) { + String convertedDate = DateUtil.convertDate(fuzzyDate); + binding.setModel(convertedDate); + binding.executePendingBindings(); + } } - public FuzzyDate getDate() { + public @Nullable FuzzyDate getDate() { return fuzzyDate; } @@ -72,18 +75,25 @@ public void onViewRecycled() { @Override public void onClick(View v) { - Calendar myCalendar = Calendar.getInstance(); - DatePickerDialog dialog = new DatePickerDialog(getContext(), this, myCalendar - .get(Calendar.YEAR), myCalendar.get(Calendar.MONTH), - myCalendar.get(Calendar.DAY_OF_MONTH)); - dialog.show(); + DatePickerDialog datePickerDialog; + if(fuzzyDate != null && fuzzyDate.isValidDate()) { + datePickerDialog = new DatePickerDialog(getContext(), this, + fuzzyDate.getYear(), fuzzyDate.getMonth() - 1, fuzzyDate.getMonth()); + } else { + Calendar calendar = Calendar.getInstance(); + datePickerDialog = new DatePickerDialog(getContext(), this, + calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), + calendar.get(Calendar.DAY_OF_MONTH)); + } + datePickerDialog.show(); } @Override - public void onDateSet(DatePicker datePicker, int y, int m, int d) { - fuzzyDate.setDate(d, m+1, y); - updateDate(); + public void onDateSet(DatePicker datePicker, int year, int month, int day) { + if(fuzzyDate == null) + fuzzyDate = new FuzzyDate(day, month + 1, year); + else + fuzzyDate.setDate(day, month + 1, year); + updateDate(); } -} - - +} \ No newline at end of file diff --git a/app/src/main/java/com/mxt/anitrend/model/entity/anilist/meta/FuzzyDate.java b/app/src/main/java/com/mxt/anitrend/model/entity/anilist/meta/FuzzyDate.java index 48763da07..b34753684 100644 --- a/app/src/main/java/com/mxt/anitrend/model/entity/anilist/meta/FuzzyDate.java +++ b/app/src/main/java/com/mxt/anitrend/model/entity/anilist/meta/FuzzyDate.java @@ -15,6 +15,12 @@ public class FuzzyDate implements Parcelable { private int month; private int year; + public FuzzyDate(int day, int month, int year) { + this.day = day; + this.month = month; + this.year = year; + } + protected FuzzyDate(Parcel in) { day = in.readInt(); month = in.readInt(); diff --git a/app/src/main/java/com/mxt/anitrend/util/DateUtil.java b/app/src/main/java/com/mxt/anitrend/util/DateUtil.java index 1ffa8a7b0..7a35796ec 100644 --- a/app/src/main/java/com/mxt/anitrend/util/DateUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/DateUtil.java @@ -33,6 +33,8 @@ public class DateUtil { KeyUtil.FALL, KeyUtil.FALL, KeyUtil.FALL, KeyUtil.WINTER }; + + private static final String dateOutputFormat = "MMM dd, yyyy", dateInputFormat = "yyyy/MM/dd"; /** * Gets current season title @@ -46,7 +48,7 @@ public class DateUtil { } public static String getMediaSeason(FuzzyDate fuzzyDate){ - SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd",Locale.getDefault()); + SimpleDateFormat format = new SimpleDateFormat(dateInputFormat,Locale.getDefault()); try { Date converted = format.parse(String.valueOf(fuzzyDate)); Calendar calendar = new GregorianCalendar(Locale.getDefault()); @@ -90,12 +92,12 @@ public static int getCurrentYear(int delta){ * Converts unix time representation into current readable time *
* - * @return A time format of dd MMM yyyy + * @return A time format of {@link DateUtil#dateOutputFormat} */ public static @Nullable String convertDate(long value) { try { if(value != 0) - return new SimpleDateFormat("dd MMM yyyy", Locale.getDefault()).format(new Date(value*1000L)); + return new SimpleDateFormat(dateOutputFormat, Locale.getDefault()).format(new Date(value*1000L)); }catch (Exception ex) { ex.printStackTrace(); } @@ -106,14 +108,14 @@ public static int getCurrentYear(int delta){ * Converts unix time representation into current readable time *
* - * @return A time format of dd MMM yyyy + * @return A time format of {@link DateUtil#dateOutputFormat} */ public static @Nullable String convertDate(FuzzyDate fuzzyDate) { try { if(fuzzyDate != null && fuzzyDate.isValidDate()) { - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd", Locale.getDefault()); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateInputFormat, Locale.getDefault()); Date converted = simpleDateFormat.parse(String.valueOf(fuzzyDate)); - return new SimpleDateFormat("dd MMM yyyy",Locale.getDefault()).format(converted); + return new SimpleDateFormat(dateOutputFormat,Locale.getDefault()).format(converted); } }catch (Exception ex) { ex.printStackTrace(); @@ -125,7 +127,7 @@ public static int getCurrentYear(int delta){ * Checks if the given data is newer than the current data on the device */ private static boolean isNewerDate(FuzzyDate fuzzyDate) throws ParseException { - SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd",Locale.getDefault()); + SimpleDateFormat format = new SimpleDateFormat(dateInputFormat,Locale.getDefault()); Date converted = format.parse(String.valueOf(fuzzyDate)); return converted.getTime() > System.currentTimeMillis(); } diff --git a/app/src/main/res/layout/custom_action_anime.xml b/app/src/main/res/layout/custom_action_anime.xml index 5356c320a..73d06d62d 100644 --- a/app/src/main/res/layout/custom_action_anime.xml +++ b/app/src/main/res/layout/custom_action_anime.xml @@ -117,8 +117,7 @@ android:id="@+id/dia_current_started_at" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_gravity="center_vertical|end" - android:clickable="true" /> + android:layout_gravity="center_vertical|end" /> + android:layout_gravity="center_vertical|end" /> + android:layout_gravity="center_vertical|end" /> + /> + - + - - - - - - + android:textAppearance="@style/TextAppearance.AppCompat.Caption" + android:text="@{model}" + tools:text="@string/TBA" /> - + android:layout_width="@dimen/lg_margin"/> + + From c1c0c104c7aadc1aa002e9aca2eaf906c5678536 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Thu, 9 Aug 2018 14:55:09 +0200 Subject: [PATCH 4/7] Fixed Duplicated Field For DatePickerDialog --- .../mxt/anitrend/base/custom/view/widget/FuzzyDateWidget.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/FuzzyDateWidget.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/FuzzyDateWidget.java index 55dd0731f..7e836734c 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/FuzzyDateWidget.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/FuzzyDateWidget.java @@ -78,7 +78,7 @@ public void onClick(View v) { DatePickerDialog datePickerDialog; if(fuzzyDate != null && fuzzyDate.isValidDate()) { datePickerDialog = new DatePickerDialog(getContext(), this, - fuzzyDate.getYear(), fuzzyDate.getMonth() - 1, fuzzyDate.getMonth()); + fuzzyDate.getYear(), fuzzyDate.getMonth() - 1, fuzzyDate.getDay()); } else { Calendar calendar = Calendar.getInstance(); datePickerDialog = new DatePickerDialog(getContext(), this, From 9a4815b67baf4f43b7a694b1829b785b71599c86 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Thu, 9 Aug 2018 20:48:53 +0200 Subject: [PATCH 5/7] Removed Build Tools & Updated Translations - Removed buildTools version from gradle - Added missing strings for date editor - Removed score range from strings --- app/build.gradle | 1 - app/src/main/res/values-ar/strings.xml | 5 ++++- app/src/main/res/values-de/strings.xml | 5 ++++- app/src/main/res/values-es/strings.xml | 5 ++++- app/src/main/res/values-fr/strings.xml | 5 ++++- app/src/main/res/values-it/strings.xml | 5 ++++- app/src/main/res/values-pl/strings.xml | 5 ++++- app/src/main/res/values/strings.xml | 3 ++- build.gradle | 1 - 9 files changed, 26 insertions(+), 9 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index f899c938e..4e1443513 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'io.fabric' android { compileSdkVersion rootProject.compileSdk - buildToolsVersion rootProject.buildTools defaultConfig { applicationId "com.mxt.anitrend" minSdkVersion rootProject.minSdk diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index cfd4033c8..01bfaf04f 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -674,7 +674,7 @@ الحالة الحلقات التي تم مشاهدتها إعادة المشاهدة - التقييم (من 0 إلى 100) + التقييم خاص زيادة الحلقات أكتب ملاحظاتك @@ -933,4 +933,7 @@ Usage Analytics Enable Usage Analytics (require app restart) Disable Usage Analytics (require app restart) + + Start Date + Finish Date diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 883f58f8c..0f4ea3d38 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -674,7 +674,7 @@ Status Episoden Erneut geschaut - Bewertung (0 – 100) + Bewertung Privat Episodenzahl erhöhen Eine Notiz anfügen @@ -933,4 +933,7 @@ Usage Analytics Enable Usage Analytics (require app restart) Disable Usage Analytics (require app restart) + + Start Date + Finish Date \ No newline at end of file diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index fade2e372..188019d87 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -674,7 +674,7 @@ elementos de tus favoritos al presionar en el icono del corazón . Estado Episodios Repetido - Puntaje (0 – 100) + Puntaje Lista privada Incrementar episodios Introduce tus apuntes @@ -933,4 +933,7 @@ elementos de tus favoritos al presionar en el icono del corazón . Análisis de uso Habilita el análisis de uso (requiere reinicio de la app) Inhabilita el análisis de uso (requiere reinicio de la app) + + Start Date + Finish Date diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index d2febb816..1a1e056f6 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -678,7 +678,7 @@ Status Episodes Rewatched - Score (0 – 100) + Score Private Increment Episodes Enter your notes @@ -937,4 +937,7 @@ Usage Analytics Enable Usage Analytics (require app restart) Disable Usage Analytics (require app restart) + + Start Date + Finish Date \ No newline at end of file diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 90e104875..9b887c5b1 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -674,7 +674,7 @@ Status Episodi Rewatched - Punteggio (0 – 100) + Punteggio Privato Aggiungi un Episodio Aggiungi nota @@ -933,4 +933,7 @@ Usage Analytics Enable Usage Analytics (require app restart) Disable Usage Analytics (require app restart) + + Start Date + Finish Date diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 3cbcc2ee3..e34f0dece 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -673,7 +673,7 @@ Status Odcinki Ponownie Obejrzane - Ocena (0 – 100) + Ocena Prywatne Zwiększ odcinki Wprowadź swoje notatki @@ -937,4 +937,7 @@ Analityka użytkowania Włącz Analityke użytkowania (wymaga ponownego uruchomienia aplikacji) Wyłącz Analityke użytkowania (wymaga ponownego uruchomienia aplikacji) + + Start Date + Finish Date diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 51a1252be..ec794c4f5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -729,7 +729,7 @@ Status Episodes Rewatched - Score (0 – 100) + Score Private Increment Episodes Enter your notes @@ -994,6 +994,7 @@ Usage Analytics Enable Usage Analytics (require app restart) Disable Usage Analytics (require app restart) + Start Date Finish Date diff --git a/build.gradle b/build.gradle index b21ae6d7e..c461fd868 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,6 @@ buildscript { minSdk = 17 versionCode = 86 versionName = '1.2.0' - buildTools = '27.0.3' butterKnife = '8.8.1' glide = '4.7.1' retrofit = '2.4.0' From f3f4a7e841b90a428429e78b74a00480b0e08ee1 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Thu, 9 Aug 2018 20:55:03 +0200 Subject: [PATCH 6/7] Custom List Scores Dispalying & Editing - Custom score types are now supported based on user preferences - Many other changes related to scoring types --- .../Mutation/SaveMediaListEntry.graphql | 4 +- .../base/custom/view/text/RatingTextView.java | 5 +- .../view/widget/AutoIncrementWidget.java | 4 +- .../view/widget/CustomSeriesAnimeManage.java | 12 +- .../view/widget/CustomSeriesManageBase.java | 5 + .../view/widget/CustomSeriesMangaManage.java | 12 +- .../custom/view/widget/ProgressWidget.java | 19 ++- .../base/custom/view/widget/ScoreWidget.java | 159 ++++++++++++++++++ .../model/entity/anilist/MediaList.java | 2 +- .../java/com/mxt/anitrend/util/KeyUtil.java | 1 + .../mxt/anitrend/util/MediaActionUtil.java | 6 +- .../com/mxt/anitrend/util/MediaListUtil.java | 29 +++- .../main/res/drawable/ic_face_white_18dp.xml | 4 + .../main/res/layout/custom_action_anime.xml | 2 +- .../main/res/layout/custom_action_manga.xml | 2 +- 15 files changed, 241 insertions(+), 25 deletions(-) create mode 100644 app/src/main/java/com/mxt/anitrend/base/custom/view/widget/ScoreWidget.java create mode 100644 app/src/main/res/drawable/ic_face_white_18dp.xml diff --git a/app/src/main/assets/graphql/Browse/Mutation/SaveMediaListEntry.graphql b/app/src/main/assets/graphql/Browse/Mutation/SaveMediaListEntry.graphql index b9fbc4ec3..23375ece0 100644 --- a/app/src/main/assets/graphql/Browse/Mutation/SaveMediaListEntry.graphql +++ b/app/src/main/assets/graphql/Browse/Mutation/SaveMediaListEntry.graphql @@ -1,5 +1,5 @@ -mutation SaveMediaListEntry($id: Int, $mediaId: Int, $status: MediaListStatus, $scoreRaw: Int, $progress: Int, $progressVolumes: Int, $repeat: Int, $priority: Int, $private: Boolean = false, $hiddenFromStatusLists: Boolean = false, $customLists: [String], $advancedScores: [Float], $notes: String, $scoreFormat: ScoreFormat = POINT_100, $startedAt: FuzzyDateInput, $completedAt: FuzzyDateInput) { - SaveMediaListEntry(id: $id, mediaId: $mediaId, status: $status, scoreRaw: $scoreRaw, progress: $progress, progressVolumes: $progressVolumes, repeat: $repeat, priority: $priority, private: $private, hiddenFromStatusLists: $hiddenFromStatusLists, customLists: $customLists, advancedScores: $advancedScores, notes: $notes, startedAt: $startedAt, completedAt: $completedAt) { +mutation SaveMediaListEntry($id: Int, $mediaId: Int, $status: MediaListStatus, $scoreRaw: Int, $score: Float, $progress: Int, $progressVolumes: Int, $repeat: Int, $priority: Int, $private: Boolean = false, $hiddenFromStatusLists: Boolean = false, $customLists: [String], $advancedScores: [Float], $notes: String, $scoreFormat: ScoreFormat = POINT_100, $startedAt: FuzzyDateInput, $completedAt: FuzzyDateInput) { + SaveMediaListEntry(id: $id, mediaId: $mediaId, status: $status, scoreRaw: $scoreRaw, score: $score, progress: $progress, progressVolumes: $progressVolumes, repeat: $repeat, priority: $priority, private: $private, hiddenFromStatusLists: $hiddenFromStatusLists, customLists: $customLists, advancedScores: $advancedScores, notes: $notes, startedAt: $startedAt, completedAt: $completedAt) { ... on MediaList { id mediaId diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/text/RatingTextView.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/text/RatingTextView.java index 17873cad5..f8e95273e 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/text/RatingTextView.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/text/RatingTextView.java @@ -75,7 +75,7 @@ private void setRating(MediaList mediaList) { if(mediaListOptions != null) switch (mediaListOptions.getScoreFormat()) { case KeyUtil.POINT_10_DECIMAL: - binding.ratingValue.setText(String.format(Locale.getDefault(),"%.2f", mediaList.getScore())); + binding.ratingValue.setText(String.format(Locale.getDefault(),"%.1f", mediaList.getScore())); break; case KeyUtil.POINT_100: case KeyUtil.POINT_10: @@ -87,6 +87,9 @@ private void setRating(MediaList mediaList) { int score = (int)mediaList.getScore(); switch (score) { case 0: + binding.ratingValue.setCompoundDrawablesWithIntrinsicBounds(CompatUtil.getDrawable(getContext(), + R.drawable.ic_face_white_18dp), null, null, null); + break; case 1: binding.ratingValue.setCompoundDrawablesWithIntrinsicBounds(CompatUtil.getDrawable(getContext(), R.drawable.ic_sentiment_dissatisfied_white_18dp), null, null, null); diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/AutoIncrementWidget.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/AutoIncrementWidget.java index 44f8cac91..745050879 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/AutoIncrementWidget.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/AutoIncrementWidget.java @@ -149,7 +149,9 @@ private void updateModelState() { model.setProgress(model.getProgress() + 1); if(MediaUtil.isIncrementLimitReached(model)) model.setStatus(KeyUtil.COMPLETED); - presenter.setParams(MediaListUtil.getMediaListParams(model)); + + presenter.setParams(MediaListUtil.getMediaListParams(model, presenter.getDatabase() + .getCurrentUser().getMediaListOptions().getScoreFormat())); presenter.requestData(requestType, getContext(), this); } } diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesAnimeManage.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesAnimeManage.java index e050571cc..f3f702202 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesAnimeManage.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesAnimeManage.java @@ -62,13 +62,16 @@ public void onInit() { public Bundle persistChanges() { model.setProgress(binding.diaCurrentProgress.getProgressCurrent()); model.setRepeat(binding.diaCurrentRewatch.getProgressCurrent()); - model.setScore(binding.diaCurrentScore.getProgressCurrent()); + + model.setScore(binding.diaCurrentScore.getScoreCurrent()); + model.setStartedAt(binding.diaCurrentStartedAt.getDate()); model.setCompletedAt(binding.diaCurrentCompletedAt.getDate()); + model.setHidden(binding.diaCurrentPrivacy.isChecked()); model.setNotes(binding.diaCurrentNotes.getFormattedText()); model.setStatus(KeyUtil.MediaListStatus[binding.diaCurrentStatus.getSelectedItemPosition()]); - return MediaListUtil.getMediaListParams(model); + return MediaListUtil.getMediaListParams(model, getMediaListOptions().getScoreFormat()); } @Override @@ -95,8 +98,9 @@ protected void bindFields() { if (model.getMedia().getEpisodes() > 0) binding.diaCurrentProgress.setProgressMaximum(model.getMedia().getEpisodes()); - binding.diaCurrentScore.setProgressMaximum(100); - binding.diaCurrentScore.setProgressCurrent((int)model.getScore()); + binding.diaCurrentScore.setScoreFormat(getMediaListOptions().getScoreFormat()); + binding.diaCurrentScore.setScoreCurrent(model.getScore()); + binding.diaCurrentProgress.setProgressCurrent(model.getProgress()); binding.diaCurrentRewatch.setProgressCurrent(model.getRepeat()); binding.diaCurrentStartedAt.setDate(model.getStartedAt()); diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesManageBase.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesManageBase.java index 1169afd5e..b800fef08 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesManageBase.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesManageBase.java @@ -12,6 +12,7 @@ import com.mxt.anitrend.base.interfaces.view.CustomView; import com.mxt.anitrend.model.entity.anilist.MediaList; +import com.mxt.anitrend.model.entity.anilist.meta.MediaListOptions; import com.mxt.anitrend.model.entity.base.MediaBase; import com.mxt.anitrend.presenter.fragment.MediaPresenter; @@ -69,6 +70,10 @@ public void setModel(MediaBase mediaBase) { populateFields(); } + public MediaListOptions getMediaListOptions() { + return presenter.getDatabase().getCurrentUser().getMediaListOptions(); + } + public @NonNull MediaList getModel() { return model; } diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesMangaManage.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesMangaManage.java index 332567dea..ad7c57b98 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesMangaManage.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesMangaManage.java @@ -62,13 +62,16 @@ public Bundle persistChanges() { model.setProgress(binding.diaCurrentChapters.getProgressCurrent()); model.setRepeat(binding.diaCurrentReread.getProgressCurrent()); model.setProgressVolumes(binding.diaCurrentVolumes.getProgressCurrent()); - model.setScore(binding.diaCurrentScore.getProgressCurrent()); + + model.setScore(binding.diaCurrentScore.getScoreCurrent()); + model.setStartedAt(binding.diaCurrentStartedAt.getDate()); model.setCompletedAt(binding.diaCurrentCompletedAt.getDate()); + model.setHidden(binding.diaCurrentPrivacy.isChecked()); model.setNotes(binding.diaCurrentNotes.getFormattedText()); model.setStatus(KeyUtil.MediaListStatus[binding.diaCurrentStatus.getSelectedItemPosition()]); - return MediaListUtil.getMediaListParams(model); + return MediaListUtil.getMediaListParams(model, getMediaListOptions().getScoreFormat()); } @Override @@ -98,8 +101,9 @@ protected void bindFields() { if(model.getMedia().getChapters() > 0) binding.diaCurrentChapters.setProgressMaximum(model.getMedia().getChapters()); - binding.diaCurrentScore.setProgressMaximum(100); - binding.diaCurrentScore.setProgressCurrent((int)model.getScore()); + binding.diaCurrentScore.setScoreFormat(getMediaListOptions().getScoreFormat()); + binding.diaCurrentScore.setScoreCurrent(model.getScore()); + binding.diaCurrentChapters.setProgressCurrent(model.getProgress()); binding.diaCurrentVolumes.setProgressCurrent(model.getProgressVolumes()); binding.diaCurrentReread.setProgressCurrent(model.getRepeat()); diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/ProgressWidget.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/ProgressWidget.java index f3f59bd1d..95c4d8bca 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/ProgressWidget.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/ProgressWidget.java @@ -20,10 +20,11 @@ public class ProgressWidget extends FrameLayout implements CustomView, View.OnClickListener, TextWatcher { - private WidgetProgressBinding binding; - private int progressMaximum, progressCurrent; - private boolean isNotDirectInput; + + protected WidgetProgressBinding binding; + protected boolean isNotDirectInput; + protected float deltaFactor; public ProgressWidget(Context context) { super(context); @@ -55,6 +56,14 @@ public void onInit() { binding.progressCurrent.setTextColor(CompatUtil.getColorFromAttr(getContext(), R.attr.contentColor)); binding.progressMaximum.setVisibility(GONE); binding.setOnClick(this); + setDefaultDeltaFactor(); + } + + /** + * Sets the default delta value for manipulating scores or progress + */ + protected void setDefaultDeltaFactor() { + deltaFactor = 1; } public void setProgressMaximum(int progressMaximum) { @@ -120,12 +129,12 @@ public void onClick(View v) { switch (v.getId()) { case R.id.progress_increment: isNotDirectInput = true; - progressChange(progressCurrent + 1); + progressChange(progressCurrent + (int)deltaFactor); isNotDirectInput = false; break; case R.id.progress_decrement: isNotDirectInput = true; - progressChange(progressCurrent - 1); + progressChange(progressCurrent - (int)deltaFactor); isNotDirectInput = false; break; } diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/ScoreWidget.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/ScoreWidget.java new file mode 100644 index 000000000..bbf949243 --- /dev/null +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/ScoreWidget.java @@ -0,0 +1,159 @@ +package com.mxt.anitrend.base.custom.view.widget; + +import android.content.Context; +import android.support.annotation.Nullable; +import android.text.Editable; +import android.text.InputType; +import android.text.TextUtils; +import android.util.AttributeSet; +import android.view.View; + +import com.mxt.anitrend.R; +import com.mxt.anitrend.util.CompatUtil; +import com.mxt.anitrend.util.KeyUtil; + +import java.text.DecimalFormat; +import java.util.Locale; + +public class ScoreWidget extends ProgressWidget { + + private float scoreMaximum, scoreCurrent; + + private @KeyUtil.ScoreFormat String scoreFormat; + + public ScoreWidget(Context context) { + super(context); + } + + public ScoreWidget(Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + } + + public ScoreWidget(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + public ScoreWidget(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + } + + /** + * Optionally included when constructing custom views + */ + @Override + public void onInit() { + super.onInit(); + } + + public void setScoreFormat(@KeyUtil.ScoreFormat String scoreFormat) { + this.scoreFormat = scoreFormat; + switch (scoreFormat) { + case KeyUtil.POINT_10_DECIMAL: + scoreMaximum = 10.0f; + break; + case KeyUtil.POINT_100: + scoreMaximum = 100; + break; + case KeyUtil.POINT_10: + scoreMaximum = 10; + break; + case KeyUtil.POINT_5: + scoreMaximum = 5; + break; + case KeyUtil.POINT_3: + scoreMaximum = 3; + + break; + } + setDefaultDeltaFactor(); + setScoreMaximum(); + } + + /** + * Sets the default delta value for manipulating scores or progress + */ + @Override + protected void setDefaultDeltaFactor() { + if(scoreFormat != null) { + switch (scoreFormat) { + case KeyUtil.POINT_10_DECIMAL: + binding.progressCurrent.setInputType(InputType.TYPE_CLASS_NUMBER | + InputType.TYPE_NUMBER_FLAG_DECIMAL); + deltaFactor = 0.1f; + break; + default: + deltaFactor = 1; + break; + } + } + } + + private void setScoreMaximum() { + binding.progressMaximum.setVisibility(VISIBLE); + if(CompatUtil.equals(scoreFormat, KeyUtil.POINT_10_DECIMAL)) + binding.progressMaximum.setText(String.format(Locale.getDefault(),"/ %.1f", scoreMaximum)); + else + binding.progressMaximum.setText(String.format(Locale.getDefault(),"/ %d", (int)scoreMaximum)); + } + + public void setScoreCurrent(float scoreCurrent) { + this.scoreCurrent = scoreCurrent; + if(CompatUtil.equals(scoreFormat, KeyUtil.POINT_10_DECIMAL)) + binding.progressCurrent.setText(String.format(Locale.getDefault(), "%.1f", scoreCurrent)); + else + binding.progressCurrent.setText(String.format(Locale.getDefault(), "%d", (int)scoreCurrent)); + } + + public float getScoreCurrent() { + return scoreCurrent; + } + + private boolean boundCheck(float delta) { + if(scoreMaximum < 1f) + return delta > -0.1f; + return delta > -0.1f && delta <= scoreMaximum; + } + + private void scoreChange(float delta) { + if (boundCheck(delta)) { + scoreCurrent = delta; + if(CompatUtil.equals(scoreFormat, KeyUtil.POINT_10_DECIMAL)) + binding.progressCurrent.setText(String.format(Locale.getDefault(), "%.1f", scoreCurrent)); + else + binding.progressCurrent.setText(String.format(Locale.getDefault(), "%d", (int)scoreCurrent)); + binding.progressCurrent.setSelection(binding.progressCurrent.getText().length()); + } + } + + @Override + public void onClick(View v) { + switch (v.getId()) { + case R.id.progress_increment: + isNotDirectInput = true; + scoreChange(getRoundedScore(scoreCurrent + deltaFactor)); + isNotDirectInput = false; + break; + case R.id.progress_decrement: + isNotDirectInput = true; + scoreChange(getRoundedScore(scoreCurrent - deltaFactor)); + isNotDirectInput = false; + break; + } + } + + private float getRoundedScore(float score) { + return Float.valueOf(new DecimalFormat("#.#").format(score)); + } + + @Override + public void afterTextChanged(Editable editable) { + if (isNotDirectInput) + return; + String currentChange = editable.toString(); + float temporaryValue = !TextUtils.isEmpty(currentChange) ? Float.parseFloat(currentChange) : 0; + if(boundCheck(temporaryValue)) + scoreCurrent = temporaryValue; + else + binding.progressCurrent.post(() -> scoreChange(scoreCurrent)); + } +} diff --git a/app/src/main/java/com/mxt/anitrend/model/entity/anilist/MediaList.java b/app/src/main/java/com/mxt/anitrend/model/entity/anilist/MediaList.java index 62c7b628f..01f1c1b23 100644 --- a/app/src/main/java/com/mxt/anitrend/model/entity/anilist/MediaList.java +++ b/app/src/main/java/com/mxt/anitrend/model/entity/anilist/MediaList.java @@ -192,7 +192,7 @@ public void setStatus(@KeyUtil.MediaListStatus String status) { this.status = status; } - public void setScore(int score) { + public void setScore(float score) { this.score = score; } diff --git a/app/src/main/java/com/mxt/anitrend/util/KeyUtil.java b/app/src/main/java/com/mxt/anitrend/util/KeyUtil.java index 89c651802..0ad82f06c 100644 --- a/app/src/main/java/com/mxt/anitrend/util/KeyUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/KeyUtil.java @@ -63,6 +63,7 @@ public interface KeyUtil { /** Media List Keys */ String arg_listStatus = "status"; + String arg_listScore= "score"; String arg_listScore_raw = "scoreRaw"; String arg_listProgress = "progress"; String arg_listProgressVolumes = "progressVolumes"; diff --git a/app/src/main/java/com/mxt/anitrend/util/MediaActionUtil.java b/app/src/main/java/com/mxt/anitrend/util/MediaActionUtil.java index 84dc6123d..e9e61c6d8 100644 --- a/app/src/main/java/com/mxt/anitrend/util/MediaActionUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/MediaActionUtil.java @@ -11,6 +11,7 @@ import com.mxt.anitrend.R; import com.mxt.anitrend.base.interfaces.event.LifecycleListener; import com.mxt.anitrend.base.interfaces.event.RetroCallback; +import com.mxt.anitrend.model.entity.anilist.meta.MediaListOptions; import com.mxt.anitrend.model.entity.base.MediaBase; import com.mxt.anitrend.model.entity.container.request.QueryContainerBuilder; import com.mxt.anitrend.presenter.widget.WidgetPresenter; @@ -45,10 +46,13 @@ private void setMediaId(long mediaId) { } private void actionPicker() { + MediaListOptions mediaListOptions = presenter.getDatabase().getCurrentUser().getMediaListOptions(); + // No need to add the parameter onList otherwise we'd have to handle an error code 404, // Instead we'd rather check if the the media has a non null mediaList item QueryContainerBuilder queryContainerBuilder = GraphUtil.getDefaultQuery(false) - .putVariable(KeyUtil.arg_id, mediaId); + .putVariable(KeyUtil.arg_id, mediaId) + .putVariable(KeyUtil.arg_scoreFormat, mediaListOptions.getScoreFormat()); presenter.getParams().putParcelable(KeyUtil.arg_graph_params, queryContainerBuilder); presenter.requestData(KeyUtil.MEDIA_WITH_LIST_REQ, context, this); diff --git a/app/src/main/java/com/mxt/anitrend/util/MediaListUtil.java b/app/src/main/java/com/mxt/anitrend/util/MediaListUtil.java index bafe0e763..ce85bad5a 100644 --- a/app/src/main/java/com/mxt/anitrend/util/MediaListUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/MediaListUtil.java @@ -4,6 +4,8 @@ import android.support.annotation.NonNull; import com.annimon.stream.Stream; +import com.mxt.anitrend.base.custom.view.widget.AutoIncrementWidget; +import com.mxt.anitrend.base.custom.view.widget.CustomSeriesManageBase; import com.mxt.anitrend.model.entity.anilist.MediaList; import com.mxt.anitrend.model.entity.anilist.meta.CustomList; import com.mxt.anitrend.model.entity.container.request.QueryContainerBuilder; @@ -13,14 +15,22 @@ public class MediaListUtil { - public static Bundle getMediaListParams(@NonNull MediaList model) { - QueryContainerBuilder queryContainer = GraphUtil.getDefaultQuery(false); + /** + * Creates query variables for updating the status of the current users lists, use cases + * @see CustomSeriesManageBase#persistChanges() + * @see AutoIncrementWidget#updateModelState() + * + * @param model the current media list item + */ + public static Bundle getMediaListParams(@NonNull MediaList model, @KeyUtil.ScoreFormat String scoreFormat) { + QueryContainerBuilder queryContainer = GraphUtil.getDefaultQuery(false) + .putVariable(KeyUtil.arg_scoreFormat, scoreFormat); if(model.getId() > 0) queryContainer.putVariable(KeyUtil.arg_id, model.getId()); queryContainer.putVariable(KeyUtil.arg_mediaId, model.getMediaId()); queryContainer.putVariable(KeyUtil.arg_listStatus, model.getStatus()); - queryContainer.putVariable(KeyUtil.arg_listScore_raw, model.getScore()); + queryContainer.putVariable(KeyUtil.arg_listScore, model.getScore()); queryContainer.putVariable(KeyUtil.arg_listNotes, model.getNotes()); queryContainer.putVariable(KeyUtil.arg_listPrivate, model.isHidden()); queryContainer.putVariable(KeyUtil.arg_listPriority, model.getPriority()); @@ -48,14 +58,25 @@ public static Bundle getMediaListParams(@NonNull MediaList model) { return bundle; } + /** + * Checks if the sorting should be done on titles + */ public static boolean isTitleSort(@KeyUtil.MediaListSort String mediaSort) { return CompatUtil.equals(mediaSort, KeyUtil.TITLE); } + /** + * Checks if the current list items progress can be incremented beyond what it is currently at + */ public static boolean isProgressUpdatable(MediaList mediaList) { - return mediaList.getMedia().getNextAiringEpisode() != null && mediaList.getMedia().getNextAiringEpisode().getEpisode() - mediaList.getProgress() >= 1; + return mediaList.getMedia().getNextAiringEpisode() != null && + mediaList.getMedia().getNextAiringEpisode().getEpisode() + - mediaList.getProgress() >= 1; } + /** + * Filters by the given search term + */ public static boolean isFilterMatch(MediaList model, String filter) { return model.getMedia().getTitle().getEnglish().toLowerCase(Locale.getDefault()).contains(filter) || model.getMedia().getTitle().getRomaji().toLowerCase(Locale.getDefault()).contains(filter) || diff --git a/app/src/main/res/drawable/ic_face_white_18dp.xml b/app/src/main/res/drawable/ic_face_white_18dp.xml new file mode 100644 index 000000000..81b084de3 --- /dev/null +++ b/app/src/main/res/drawable/ic_face_white_18dp.xml @@ -0,0 +1,4 @@ + + + + diff --git a/app/src/main/res/layout/custom_action_anime.xml b/app/src/main/res/layout/custom_action_anime.xml index 73d06d62d..15d2cb305 100644 --- a/app/src/main/res/layout/custom_action_anime.xml +++ b/app/src/main/res/layout/custom_action_anime.xml @@ -47,7 +47,7 @@ android:layout_gravity="center_vertical|start" android:text="@string/dialog_title_score" /> - - Date: Thu, 9 Aug 2018 21:01:09 +0200 Subject: [PATCH 7/7] Minor Tweaks & Improvements - Added current user profile fetching on application startup - Invalidated and executed pending bindings on AvatarIndicator views after change --- .../base/custom/view/image/AvatarIndicatorView.java | 8 +++++--- .../com/mxt/anitrend/presenter/base/BasePresenter.java | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/image/AvatarIndicatorView.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/image/AvatarIndicatorView.java index 1deb8a791..8f5bb4428 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/image/AvatarIndicatorView.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/image/AvatarIndicatorView.java @@ -63,14 +63,12 @@ public void onInit() { private void checkLastSyncTime() { if(presenter.getApplicationPref().isAuthenticated()) { if((currentUser = presenter.getDatabase().getCurrentUser()) != null) { + AvatarImageView.setImage(binding.userAvatar, currentUser.getAvatar()); if (currentUser.getUnreadNotificationCount() > 0) { binding.notificationCount.setText(String.valueOf(currentUser.getUnreadNotificationCount())); showNotificationWidget(); } else hideNotificationCountWidget(); - - AvatarImageView.setImage(binding.userAvatar, currentUser.getAvatar()); - invalidate(); } else hideNotificationCountWidget(); } @@ -94,11 +92,15 @@ public void onModelChanged(BaseConsumer consumer) { private void showNotificationWidget() { binding.notificationCount.setVisibility(VISIBLE); binding.container.setVisibility(VISIBLE); + binding.executePendingBindings(); + invalidate(); } private void hideNotificationCountWidget() { binding.notificationCount.setVisibility(GONE); binding.container.setVisibility(GONE); + binding.executePendingBindings(); + invalidate(); } @Override diff --git a/app/src/main/java/com/mxt/anitrend/presenter/base/BasePresenter.java b/app/src/main/java/com/mxt/anitrend/presenter/base/BasePresenter.java index b8f11d799..e72645c24 100644 --- a/app/src/main/java/com/mxt/anitrend/presenter/base/BasePresenter.java +++ b/app/src/main/java/com/mxt/anitrend/presenter/base/BasePresenter.java @@ -15,6 +15,7 @@ import com.mxt.anitrend.model.entity.base.UserBase; import com.mxt.anitrend.model.entity.crunchy.MediaContent; import com.mxt.anitrend.model.entity.crunchy.Thumbnail; +import com.mxt.anitrend.service.AuthenticatorService; import com.mxt.anitrend.service.TagGenreService; import com.mxt.anitrend.util.CompatUtil; @@ -146,7 +147,8 @@ public void checkValidAuth() { if(databaseHelper.getCurrentUser() == null) { Log.e("checkValidAuth", "Last attempt to authenticate failed, refreshing session!"); WebTokenRequest.invalidateInstance(getContext()); - } + } else + getContext().startService(new Intent(getContext(), AuthenticatorService.class)); } } }