Skip to content

Commit

Permalink
Merge branch 'feature/list-editor' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
wax911 committed Aug 9, 2018
2 parents 7c8868b + 1d69e41 commit ddb9772
Show file tree
Hide file tree
Showing 36 changed files with 726 additions and 193 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<!--- Provide a general summary of the issue in the Title above -->
# 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
<!--- Tell us what should happen -->

- [ ] Bug
- [ ] Feature

# Expected Behavior
<!--- Tell us what should happen -->
Expand Down Expand Up @@ -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 -->

Please include any relevant log snippets or files here, if any otherwise remove this heading section
46 changes: 46 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -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:
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

- [ ] 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
<!--- Describe your changes in detail -->

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->

## How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, tests ran to see how -->
<!--- your change affects other areas of the code, etc. -->

## Screenshots (if appropriate):

## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [ ] 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)

<!--- Be kind to code reviewers, please try to keep pull requests as small and focused as possible :) -->

**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).
28 changes: 0 additions & 28 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md

This file was deleted.

4 changes: 2 additions & 2 deletions app/.travic-ci/secrets
Original file line number Diff line number Diff line change
@@ -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"
1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ apply plugin: 'io.fabric'

android {
compileSdkVersion rootProject.compileSdk
buildToolsVersion rootProject.buildTools
defaultConfig {
applicationId "com.mxt.anitrend"
minSdkVersion rootProject.minSdk
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 5 additions & 7 deletions app/src/main/java/com/mxt/anitrend/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

/**
* Created by max on 2017/06/09.
* Activity base <T type of data model, S extends CommonPresenter>
* Activity base <M type of data model, P extends CommonPresenter>
*/

public abstract class ActivityBase<M, P extends CommonPresenter> extends AppCompatActivity implements Observer<M>, CommonPresenter.AbstractPresenter<P>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -94,11 +92,15 @@ public void onModelChanged(BaseConsumer<User> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,23 @@ 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
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
Expand All @@ -83,19 +89,22 @@ 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.diaCurrentScore.setScoreFormat(getMediaListOptions().getScoreFormat());
binding.diaCurrentScore.setScoreCurrent(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);
}
Expand All @@ -106,7 +115,7 @@ protected void bindFields() {
@Override
public void onViewRecycled() {
super.onViewRecycled();
if(binding != null)
if (binding != null)
binding.unbind();
}

Expand Down Expand Up @@ -141,4 +150,4 @@ public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l)
public void onNothingSelected(AdapterView<?> adapterView) {

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -69,6 +70,10 @@ public void setModel(MediaBase mediaBase) {
populateFields();
}

public MediaListOptions getMediaListOptions() {
return presenter.getDatabase().getCurrentUser().getMediaListOptions();
}

public @NonNull MediaList getModel() {
return model;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +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
Expand Down Expand Up @@ -96,11 +101,14 @@ 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());
binding.diaCurrentStartedAt.setDate(model.getStartedAt());
binding.diaCurrentCompletedAt.setDate(model.getCompletedAt());

binding.diaCurrentStatus.setOnItemSelectedListener(this);
}
Expand Down
Loading

0 comments on commit ddb9772

Please sign in to comment.